[PATCH v2] libstdc++: Add P1206R7 from_range members to ordered sets [PR111055]
Jonathan Wakely
jwakely@redhat.com
Tue Mar 18 12:11:32 GMT 2025
On Tue, 18 Mar 2025 at 12:04, Tomasz Kaminski wrote:
> On Tue, Mar 18, 2025 at 12:55 PM Jonathan Wakely <jwakely@redhat.com> wrote:
>>
>> On 17/03/25 09:21 +0100, Tomasz Kamiński wrote:
>> >+ */
>> >+ template<__detail::__container_compatible_range<_Key> _Rg>
>> >+ void
>> >+ insert_range(_Rg&& __rg)
>> >+ {
>> >+ auto __first = ranges::begin(__rg);
>> >+ const auto __last = ranges::end(__rg);
>> >+ using _Rv = __remove_cvref_t<ranges::range_value_t<_Rg>>;
>>
>> This can just use remove_cvref_t because it's C++23 code. We need to
>> use __remove_cvref_t for C++11/14/17 because std::remove_cvref_t
>> wasn't added until C++20.
>
> I thought that we would prefer to use internal __remove_cvref_t when possible,
> as we could later define it as __remove_reference(__remove_cv_t(T)), so
> we will not trigger instantations of the type_traits.
That's not possible because we use __remove_cvref_t in return types
and default template arguments, which means it needs to be mangled.
Unlike with Clang, GCC's __remove_reference, __remove_cv etc built-ins
cannot be mangled (intentionally).
We could define *another* alias, e.g. __remove_cvref_, which could use
the built-ins directly, and would not be allowed in signatures and
mangled contexts. But that doesn't exist today, and __remove_cvref_t
won't become that, so I think we might as well just use remove_cvref_t
here. If we add a non-mangled alias later, we would already need to
find all the places that could benefit from it and change them.
More information about the Libstdc++
mailing list