[v3 PATCH] Implement LWG 2758.
Jonathan Wakely
jwakely@redhat.com
Tue Aug 16 12:58:00 GMT 2016
On 16/08/16 12:52 +0100, Jonathan Wakely wrote:
>On 10/08/16 10:50 +0300, Ville Voutilainen wrote:
>>diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
>>index 59f1c64..89e2100 100644
>>--- a/libstdc++-v3/include/bits/basic_string.h
>>+++ b/libstdc++-v3/include/bits/basic_string.h
>>@@ -1227,9 +1227,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
>> * @param __n The number of characters to append from the string_view.
>> * @return Reference to this string.
>> */
>>- basic_string& append(__sv_type __sv,
>>+ template <typename _Tp,
>>+ enable_if_t<is_convertible_v<const _Tp&, __sv_type>,
>>+ bool> = true>
>>+ basic_string& append(const _Tp& __svt,
>> size_type __pos, size_type __n = npos)
>
>I would prefer the enable_if constraint to be on the return type, so
>there is only one template parameter:
>
> template <typename _Tp>
> enable_if_t<is_convertible_v<const _Tp&, __sv_type>, basic_string&>
> append(const _Tp& __svt,
> size_type __pos, size_type __n = npos)
>
>However these function templates appear to have a design problem, see
>PR 77264.
This patch constrains the new overloads using:
template<typename _Tp, typename _Res>
using _If_sv = enable_if_t<
__and_<is_convertible<const _Tp&, __sv_type>,
__not_<is_convertible<const _Tp&, const _CharT*>>>::value,
_Res>;
so that anything convertible to const _CharT* goes to the same
overload as would have been chosen prior to C++17.
I'm testing this now but won't commit it until it's clear this is a
sensible resolution for LWG 2758.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 11428 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20160816/7f077eff/attachment.bin>
More information about the Libstdc++
mailing list