libstdc++: Implement LWG 3706 for COW strings

The basic_string deduction guides are defined for the old ABI, but the
tests are currently disabled. This is because a single case fails when
using the old ABI, which is just because LWG 3706 isn't implemented for
the old ABI. That can be done easily, and the tests can be enabled.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI]
	(basic_string(const _CharT*, const _Alloc&)): Constrain to
	require an allocator-like type to fix CTAD ambiguity (LWG 3706).
	* testsuite/21_strings/basic_string/cons/char/deduction.cc:
	Remove dg-skip-if.
	* testsuite/21_strings/basic_string/cons/wchar_t/deduction.cc:
	Likewise.
This commit is contained in:
Jonathan Wakely 2020-10-14 11:52:26 +01:00
parent 4d2a56a0f7
commit dc38e25524
3 changed files with 7 additions and 2 deletions

View File

@ -3612,12 +3612,19 @@ _GLIBCXX_END_NAMESPACE_CXX11
*/
basic_string(const _CharT* __s, size_type __n,
const _Alloc& __a = _Alloc());
/**
* @brief Construct string as copy of a C string.
* @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());
/**
* @brief Construct string as multiple characters.
* @param __n Number of characters.

View File

@ -17,7 +17,6 @@
// { dg-options "-std=gnu++17" }
// { dg-do compile { target c++17 } }
// { dg-xfail-if "COW string missing deduction guides" { ! cxx11-abi } }
#include <string>
#include <testsuite_iterators.h>

View File

@ -17,7 +17,6 @@
// { dg-options "-std=gnu++17" }
// { dg-do compile { target c++17 } }
// { dg-xfail-if "COW string missing deduction guides" { ! cxx11-abi } }
#include <string>
#include <testsuite_iterators.h>