From cfce831e6c3288fd4a8989eb9055faba69b3da3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kr=C3=BCgler?= Date: Fri, 22 Dec 2023 15:01:10 +0100 Subject: [PATCH] New issue from Jan Schultke: "basic_string accidentally fails to meet the reversible container requirements" --- xml/issue4029.xml | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 xml/issue4029.xml diff --git a/xml/issue4029.xml b/xml/issue4029.xml new file mode 100644 index 0000000000..56299397cf --- /dev/null +++ b/xml/issue4029.xml @@ -0,0 +1,121 @@ + + + + +<tt>basic_string</tt> accidentally fails to meet the reversible container requirements +
+Jan Schultke +18 Dec 2023 +99 + + +

+The complexity requirements for a reversible container () are that each +function must have constant complexity. The corresponding member functions in +have no complexity requirements, and basic_string unintentionally is not a reversible container +(unless the implementation coincidentally provides constant complexity member functions). +

+
+ + +

+This wording is relative to . +

+ +
+

+[Drafting Note: The proposed wording is similar to the specification in p2 +and suggests to simply strike , because it doesn't say anything new compared to + and . +

+Alternatively, one could add a +

+Complexity: Constant. +

+paragraph to each function in , but that would be less clearer and would not +explicitly say basic_string meets the reversible container requirements. +] +

+
+ +
    + +
  1. Modify as indicated:

    + +
    +

    +-2- A specialization of basic_string is a contiguous container and reversible container +(). +

    +-3- In all cases, [data(), data() + size()] is a valid range, data() + size() points at +an object with value charT() (a "null terminator"), and size() <= capacity() is true. +

    +
    +namespace std {
    +  template<class charT, class traits = char_traits<charT>,
    +           class Allocator = allocator<charT>>
    +  class basic_string {
    +    […]
    +    // , iterators
    +    constexpr iterator begin() noexcept;
    +    constexpr const_iterator begin() const noexcept;
    +    constexpr iterator end() noexcept;
    +    constexpr const_iterator end() const noexcept;
    +  
    +    constexpr reverse_iterator rbegin() noexcept;
    +    constexpr const_reverse_iterator rbegin() const noexcept;
    +    constexpr reverse_iterator rend() noexcept;
    +    constexpr const_reverse_iterator rend() const noexcept;
    +  
    +    constexpr const_iterator cbegin() const noexcept;
    +    constexpr const_iterator cend() const noexcept;
    +    constexpr const_reverse_iterator crbegin() const noexcept;
    +    constexpr const_reverse_iterator crend() const noexcept;
    +  
    +    // , capacity
    +    […]
    +  };
    +  […]
    +}
    +
    +[…] +
    +
  2. + +
  3. Remove subclause in its entirety:

    + +
    +

    +23.4.3.4 Iterator support [string.iterators] +

    +
    +constexpr iterator begin() noexcept;
    +constexpr const_iterator begin() const noexcept;
    +constexpr const_iterator cbegin() const noexcept;
    +
    +
    +

    +-1- Returns: An iterator referring to the first character in the string. +

    +
    +[…] +
    +constexpr reverse_iterator rend() noexcept;
    +constexpr const_reverse_iterator rend() const noexcept;
    +constexpr const_reverse_iterator crend() const noexcept;
    +
    +
    +

    +-4- Returns: An iterator which is semantically equivalent to reverse_iterator(begin()). +

    +
    +
    + +
  4. + +
+ + +
+ +