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

2938. basic_string_view::const_iterator should be literal types

Section: 23.3.3 [string.view.template] Status: Resolved Submitter: Antony Polukhin Opened: 2017-03-01 Last modified: 2020-09-06

Priority: 2

View all other issues in [string.view.template].

View all issues with Resolved status.

Discussion:

Force the literal type requirement for the const_iterator in the std::basic_string_view so that iterators of std::basic_string_view could be used in constexpr functions.

[2017-03-02, Kona]

Wording tweaks suggested by LWG applied.

[2017-03-02, Tim Song comments]

I don't believe the blanket "all operations" wording is quite correct.

First, T t; (required by DefaultConstructible) isn't usable in a constant expression if the iterator is a pointer, since it would leave it uninitialized.

Second, an explicit destructor call u.~T() (required by Destructible) isn't usable if the iterator is a class type because it explicitly invokes a non-constexpr function (the destructor); see [expr.const]/2.2.

[2017-03-04, Kona]

Set priority to 2. Lisa and Alisdair to work with Antony to come up with better wording. The same wording can be used for 2897.

[2017-11 Albuquerque Saturday issues processing]

P0858R0 (adopted on Sat; to be moved in Jacksonville) will resolve this.

[2018-06 Rapperswil Wednesday issues processing]

This was resolved by P0858, which was adopted in Jacksonville.

Proposed resolution:

This wording is relative to N4640.

  1. Add to the end of the 23.3.3 [string.view.template] section:

    -1- In every specialization basic_string_view<charT, traits>, the type traits shall satisfy the character traits requirements (21.2), and the type traits::char_type shall name the same type as charT.

    -?- All operations on iterator and const_iterator that are required to satisfy the random access iterator requirements are usable in constant expressions.