Title
Forbid assigning an rvalue basic_string to basic_string_view
Status
nad
Section
[string.view.template]
Submitter
Antony Polukhin

Created on 2018-02-19.00:00:00 last changed 20 months ago

Messages

Date: 2022-08-24.18:54:27

Proposed resolution:

This wording is relative to N4727.

  1. Change [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);
    […]
    
Date: 2022-08-24.00:00:00

[ 2022-08-24 Status changed: Open → NAD. ]

LWG telecon: close based on LEWG direction. "This makes string_view depend on basic_string." "Request a paper with implementation if someone really wants this."

Date: 2020-05-15.00:00:00

[ 2020-05-28; LEWG issue reviewing ]

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

SF F N A SA
15 5 1 0 0
Date: 2018-06-18.00:00:00

[ 2018-06-18 after reflector discussion ]

Priority set to 2; status to LEWG

Date: 2018-02-19.00:00:00

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 );
bar(foo());

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

History
Date User Action Args
2022-08-24 18:54:27adminsetmessages: + msg12711
2022-08-24 18:54:27adminsetstatus: open -> nad
2020-05-31 09:54:47adminsetmessages: + msg11313
2020-05-31 09:54:47adminsetstatus: lewg -> open
2018-06-19 05:49:11adminsetmessages: + msg9930
2018-06-19 05:49:11adminsetstatus: new -> lewg
2018-03-03 14:00:07adminsetmessages: + msg9692
2018-02-19 00:00:00admincreate