@@ -1176,6 +1176,13 @@ requirements of the license of GCC.
they will allow conversions from other types to the value_type.
</para></listitem></varlistentry>
+ <varlistentry xml:id="manual.bugs.dr3076"><term><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&DR;#3076">3076</link>:
+ <emphasis><code>basic_string</code> CTAD ambiguity
+ </emphasis>
+ </term>
+ <listitem><para>Change constructors to constrained templates.
+ </para></listitem></varlistentry>
+
</variablelist>
</section>
@@ -506,6 +506,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* @param __s Source C string.
* @param __a Allocator to use (default is default allocator).
*/
+#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 3076. basic_string CTAD ambiguity
+ template<typename = _RequireAllocator<_Alloc>>
+#endif
basic_string(const _CharT* __s, const _Alloc& __a = _Alloc())
: _M_dataplus(_M_local_data(), __a)
{ _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
@@ -516,6 +521,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* @param __c Character to use.
* @param __a Allocator to use (default is default allocator).
*/
+#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 3076. basic_string CTAD ambiguity
+ template<typename = _RequireAllocator<_Alloc>>
+#endif
basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
: _M_dataplus(_M_local_data(), __a)
{ _M_construct(__n, __c); }
@@ -35,6 +35,12 @@
# define _GLIBCXX_USE_CXX11_ABI 1
#endif
+// Prevent the basic_string(const _CharT*, const _Alloc&) and
+// basic_string(size_type, _CharT, const _Alloc&) constructors from being
+// replaced by constrained function templates, so that we instantiate the
+// pre-C++17 definitions.
+#define _GLIBCXX_DEFINING_STRING_INSTANTIATIONS 1
+
#include <string>
// Instantiation configuration.
@@ -138,3 +138,20 @@ test05()
std::basic_string s4(sv, 2u, 6u, a);
check_type<std::string>(s4);
}
+
+void
+test06()
+{
+ // LWG 3076 basic_string CTAD ambiguity
+ using namespace std;
+ string s0;
+
+ basic_string s1(s0, 1, 1);
+ check_type<std::string>(s1);
+
+ basic_string s2("cat"sv, 1, 1);
+ check_type<std::string>(s2);
+
+ basic_string s3("cat", 1);
+ check_type<std::string>(s3);
+}
@@ -97,3 +97,20 @@ test05()
std::basic_string s4(sv, 2u, 6u, a);
check_type<std::wstring>(s4);
}
+
+void
+test06()
+{
+ // LWG 3076 basic_string CTAD ambiguity
+ using namespace std;
+ wstring s0;
+
+ basic_string s1(s0, 1, 1);
+ check_type<std::wstring>(s1);
+
+ basic_string s2(L"cat"sv, 1, 1);
+ check_type<std::wstring>(s2);
+
+ basic_string s3(L"cat", 1);
+ check_type<std::wstring>(s3);
+}