On Wed, 19 Mar 2025 at 11:48, Tomasz Kaminski <tkami...@redhat.com> wrote:
>
>
>
>
> On Wed, Mar 19, 2025 at 12:36 PM Jonathan Wakely <jwak...@redhat.com> wrote:
>>
>> On 19/03/25 09:32 +0100, Tomasz Kamiński wrote:
>> >This patch implements LWG2713 by adding missing allocator aware version of
>> >unordered associative containers constructors accepting only "range"
>> >(pair of iterators, initializer_list, or from_range), and corresponding
>> >deduction guides.
>> >
>> >In addition the std::ranges::to<std::unordered_set>(alloc) is well-formed,
>> >likewise for rest of unordered containers.
>> >
>> >libstdc++-v3/ChangeLog:
>> >
>> >       * include/bits/unordered_map.h (unordered_map):
>> >       Define constructors accepting:
>> >       (_InputIterator, _InputIterator, const allocator_type&),
>> >       (initializer_list<value_type>, const allocator_type&),
>> >       (from_range_t, _Rg&&, const allocator_type&)
>> >       (unordered_multimap): Likewise.
>> >       * include/bits/unordered_set.h (unordered_set):
>> >       Define constructors and deduction guide accepting:
>> >       (_InputIterator, _InputIterator, const allocator_type&),
>> >       (initializer_list<value_type>, const allocator_type&).
>> >       Define constructor (from_range_t, _Rg&&, const allocator_type&).
>> >       (unordered_multiset): Likewise.
>> >       * testsuite/23_containers/unordered_map/cons/66055.cc: New tests.
>> >       * testsuite/23_containers/unordered_map/cons/deduction.cc: New tests.
>> >       * testsuite/23_containers/unordered_map/cons/from_range.cc: New 
>> > tests.
>> >       * testsuite/23_containers/unordered_multimap/cons/66055.cc: New 
>> > tests.
>> >       * testsuite/23_containers/unordered_multimap/cons/deduction.cc:
>> >       New tests.
>> >       * testsuite/23_containers/unordered_multimap/cons/from_range.cc:
>> >       New tests.
>> >       * testsuite/23_containers/unordered_multiset/cons/66055.cc: New 
>> > tests.
>> >       * testsuite/23_containers/unordered_multiset/cons/deduction.cc:
>> >       New tests.
>> >       * testsuite/23_containers/unordered_multiset/cons/from_range.cc:
>> >       New tests.
>> >       * testsuite/23_containers/unordered_set/cons/66055.cc: New tests.
>> >       * testsuite/23_containers/unordered_set/cons/deduction.cc: New tests.
>> >       * testsuite/23_containers/unordered_set/cons/from_range.cc: New 
>> > tests.
>> >       * testsuite/std/ranges/conv/1.cc: New tests.
>> >---
>> >I have added ranges::to test, as they provide additional motivation.
>> >Tested on x86_64-linux. OK for trunk?
>>
>> I think we should be a little cautious here, because we're very close
>> to the GCC 15 release and this is changing C++11/14/17 code as well.
>> We don't want a last-minute regression this close to the release.
>>
>> Although these constructors all look correct, they introduce the
>> possibility of new ambiguities just by changing the overload set.
>>
>> The C++23 from_range_t constructors are OK to add now. For the rest of
>> them, I think I'd prefer to guard them with #if __cplusplus >= 202002L
>> for now, and open a bugzilla bug reminding us to remove those #if
>> guards for GCC 16.
>
> I think it would be better to just reduce the GCC15 patch to only new
> from_range constructors. I think if we are concerned with new ambiguities
> for old constructors we should not add them conditionally.
> Otherwise we are risking breaking old code when compiled with new standard.

Yes, but the new standards are considered experimental so a bit of
experimental breakage is acceptable ;-)

But I'm fine with waiting for GCC 16 and then adding them for all
standards >= C++11, and if it breaks things we'll have nearly a whole
year to find out before making a release (and we can give that
feedback to LWG).

>
> I will prepare a partial patch.

Thanks.

Reply via email to