Title
Resolution for LWG 2742 introduces ambiguities
Status
nad
Section
[string.cons]
Submitter
Jonathan Wakely

Created on 2016-11-15.00:00:00 last changed 87 months ago

Messages

Date: 2017-01-27.00:00:00

[ 2017-01-27 Telecon ]

NAD

Date: 2016-12-15.00:00:00

[ 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.

Date: 2017-01-25.17:55:25

The new constructor added for LWG 2742 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, 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.

  1. Modify the new basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); constructor in [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 by basic_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>> is true and is_convertible_v<const T&, const charT*> is false.

History
Date User Action Args
2017-01-30 15:17:53adminsetmessages: + msg8799
2017-01-30 15:17:53adminsetstatus: new -> nad
2016-11-26 19:54:12adminsetmessages: + msg8688
2016-11-15 00:00:00admincreate