This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.

2778. basic_string_view is missing constexpr

Section: 23.3 [string.view] Status: C++17 Submitter: Billy Robert O'Neal III Opened: 2016-09-30 Last modified: 2017-07-30

Priority: 0

View all other issues in [string.view].

View all issues with C++17 status.

Discussion:

basic_string_view was not updated to account for other library machinery made constexpr in Oulu. Now that reverse_iterator is constexpr there's no reason the reverse range functions can't be. Also, now that we have C++14 relaxed constexpr, we can also take care of the assignment operator and copy.

[Issues processing Telecon 2016-10-7]

split off the copy into its' own issue 2780

P0; set what's left to Tentatively Ready

Previous resolution [SUPERSEDED]:

This wording is relative to N4606.

  1. In 23.3.3 [string.view.template], add constexpr to the assignment operator:

    constexpr basic_string_view& operator=(const basic_string_view&) noexcept = default;
    
  2. In 23.3.3 [string.view.template], add constexpr to the reverse range functions:

    constexpr const_reverse_iterator rbegin() const noexcept;
    constexpr const_reverse_iterator rend() const noexcept;
    constexpr const_reverse_iterator crbegin() const noexcept;
    constexpr const_reverse_iterator crend() const noexcept;
    
  3. In 23.3.3.4 [string.view.iterators], add constexpr to the reverse range functions:

    constexpr const_reverse_iterator rbegin() const noexcept;
    constexpr const_reverse_iterator crbegin() const noexcept;
    

    -6- Returns: const_reverse_iterator(end())

    constexpr const_reverse_iterator rend() const noexcept;
    constexpr const_reverse_iterator crend() const noexcept;
    

    -7- Returns: const_reverse_iterator(begin())

  4. In 23.3.3 [string.view.template], add constexpr to copy:

    constexpr size_type copy(charT* s, size_type n, size_type pos = 0) const;
    
  5. In 23.3.3.8 [string.view.ops], add constexpr to copy:

    constexpr size_type copy(charT* s, size_type n, size_type pos = 0) const;
    

Proposed resolution:

This wording is relative to N4606.

  1. In 23.3.3 [string.view.template], add constexpr to the assignment operator:

    constexpr basic_string_view& operator=(const basic_string_view&) noexcept = default;
    
  2. In 23.3.3 [string.view.template], add constexpr to the reverse range functions:

    constexpr const_reverse_iterator rbegin() const noexcept;
    constexpr const_reverse_iterator rend() const noexcept;
    constexpr const_reverse_iterator crbegin() const noexcept;
    constexpr const_reverse_iterator crend() const noexcept;
    
  3. In 23.3.3.4 [string.view.iterators], add constexpr to the reverse range functions:

    constexpr const_reverse_iterator rbegin() const noexcept;
    constexpr const_reverse_iterator crbegin() const noexcept;
    

    -6- Returns: const_reverse_iterator(end())

    constexpr const_reverse_iterator rend() const noexcept;
    constexpr const_reverse_iterator crend() const noexcept;
    

    -7- Returns: const_reverse_iterator(begin())