[PATCH] D29863: [libc++] Fix PR 31938 - std::basic_string constructors use non-deductible parameter types.

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 13 15:50:13 PST 2017


EricWF added inline comments.


================
Comment at: include/string:782
     _LIBCPP_INLINE_VISIBILITY
     basic_string(const value_type* __s, size_type __n);
     _LIBCPP_INLINE_VISIBILITY
----------------
rsmith wrote:
> EricWF wrote:
> > rsmith wrote:
> > > Did you skip this one intentionally?
> > Yes. `size_type`  is a typedef for `allocator_traits<Allocator>::size_type`, This causes the `basic_string(CharT*, Allocator const&)` to always be chosen instead, resulting in a incorrect allocator type.
> I don't think it will always be chosen instead; if the argument is of type `size_t`, the `(const CharT*, size_type)` overload should be chosen.
OK, so it's not that it should always be taken. Instead I think any attempt to form the implicit deduction guide overloads for such a call will end up attempting to evaluate `std::basic_string<char, char_traits<char>, unsigned long long>` which is an ill-formed instantiation of `basic_string`.


So if building the overload set were to succeed then yes, the `(const CharT*, size_type)` would be callable with an argument of `size_type`. However it seems that the overload set is poisoned by `(const CharT*, Allocator)`





https://reviews.llvm.org/D29863





More information about the cfe-commits mailing list