This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.
Section: 27.4.3.3 [string.cons] Status: NAD Submitter: Jonathan Wakely Opened: 2016-11-15 Last modified: 2017-01-30
Priority: Not Prioritized
View all other issues in [string.cons].
View all issues with NAD status.
Discussion:
The new constructor added for LWG 2742(i) causes an ambiguity when attempting to construct from a (non-const) char*
char s[] = "whoops"; std::string str(s, 2, 4);
This is the same problem discussed in 2758(i), and the fix is the same: disable that new constructor if T
is convertible to const_pointer
, so that the old constructor is used instead.
Previous resolution [SUPERSEDED]:
This wording is relative to N4606.
Modify the new
basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator());
constructor in 27.4.3.3 [string.cons] as shown:template<class T> basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator());-?- Effects: Creates a variable,
sv
, as if bybasic_string_view<charT, traits> sv = t;
and then behaves the same as:basic_string(sv.substr(pos, n), a)-?- Remarks: This constructor shall not participate in overload resolution unless
is_convertible_v<const T&, basic_string_view<charT, traits>>
istrue
andis_convertible_v<const T&, const charT*>
isfalse
.
[2016-12-21, Jonathan comments and reommends NAD]
Tim Song pointed out that this constructor isn't ambiguous, and I can no longer reproduce the errors I was getting, so I think this issue should be resolved NAD. The code snippet in the issue discussion compiles OK without the proposed change.
[2017-01-27 Telecon]
NAD
Proposed resolution: