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

3068. Forbid assigning an rvalue basic_string to basic_string_view

Section: 23.3.3 [string.view.template] Status: Open Submitter: Antony Polukhin Opened: 2018-02-19 Last modified: 2020-09-06

Priority: 2

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

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

View all issues with Open status.


It is known that we cannot disable move construction of basic_string_view from rvalues of basic_string, because it breaks a valid use case:

string foo();
void bar(string_view );

Though it is still possible to disable an absolutely wrong case of assigning an rvalue basic_string to basic_string_view:

string_view sw = "Hello";
sw = foo();

Some tests that make sure that other use cases are not affected are available here

[2018-06-18 after reflector discussion]

Priority set to 2; status to LEWG

[2020-05-28; LEWG issue reviewing]

LEWG issue processing voted to reject 3068 as NAD. Status change to Open.

15 5 1 0 0

Proposed resolution:

This wording is relative to N4727.

  1. Change 23.3.3 [string.view.template], class template basic_string_view synopsis, as indicated:

    // [string.view.cons], construction and assignment
    constexpr basic_string_view() noexcept;
    constexpr basic_string_view(const basic_string_view&) noexcept = default;
    constexpr basic_string_view& operator=(const basic_string_view&) noexcept = default;
    template <class A>
    basic_string_view& operator=(const basic_string<charT, traits, A>&&) = delete;
    constexpr basic_string_view(const charT* str);
    constexpr basic_string_view(const charT* str, size_type len);