Index: include/string =================================================================== --- include/string +++ include/string @@ -775,13 +775,13 @@ _LIBCPP_INLINE_VISIBILITY basic_string(basic_string&& __str, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY basic_string(const value_type* __s); + _LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s); _LIBCPP_INLINE_VISIBILITY - basic_string(const value_type* __s, const allocator_type& __a); + basic_string(const _CharT* __s, const _Allocator& __a); _LIBCPP_INLINE_VISIBILITY basic_string(const value_type* __s, size_type __n); _LIBCPP_INLINE_VISIBILITY - basic_string(const value_type* __s, size_type __n, const allocator_type& __a); + basic_string(const _CharT* __s, size_type __n, const _Allocator& __a); _LIBCPP_INLINE_VISIBILITY basic_string(size_type __n, value_type __c); _LIBCPP_INLINE_VISIBILITY @@ -1557,7 +1557,7 @@ template inline _LIBCPP_INLINE_VISIBILITY -basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s) +basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s) { _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); __init(__s, traits_type::length(__s)); @@ -1568,7 +1568,7 @@ template inline _LIBCPP_INLINE_VISIBILITY -basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, const allocator_type& __a) +basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a) : __r_(__a) { _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); @@ -1591,7 +1591,7 @@ template inline _LIBCPP_INLINE_VISIBILITY -basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, size_type __n, const allocator_type& __a) +basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) : __r_(__a) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); Index: test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp =================================================================== --- /dev/null +++ test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// Clang does not implement deduction guides yet. +// XFAIL: clang, apple-clang + +// + +// Test that the constructors offered by std::basic_string are formulated +// so they're compatible with implicit deduction guides. + +#include +#include + +#include "test_macros.h" +#include "test_allocator.h" + + +template > +using BStr = std::basic_string, Alloc>; + + +int main() +{ + { + std::basic_string s = "hello world"; + std::basic_string w(L"hello world"); + + ASSERT_SAME_TYPE(decltype(s), std::basic_string); + ASSERT_SAME_TYPE(decltype(w), std::basic_string); + } + { + std::basic_string s("hello world", test_allocator{}); + ASSERT_SAME_TYPE(decltype(s), BStr>); + } + { + std::basic_string s("hello world", 2ull, test_allocator{}); + std::basic_string w(L"hello world", 2ull, test_allocator{}); + ASSERT_SAME_TYPE(decltype(s), BStr>); + ASSERT_SAME_TYPE(decltype(w), BStr>); + + } + { + std::string const s1; + std::basic_string s(s1); + ASSERT_SAME_TYPE(decltype(s), std::string); + + std::basic_string w = std::wstring{}; + ASSERT_SAME_TYPE(decltype(w), std::wstring); + } +}