]> git.ipfire.org Git - thirdparty/gcc.git/commit - libstdc++-v3/testsuite/23_containers/priority_queue/deduction.cc
libstdc++: Implement P1518R2 for container deduction guides
authorJonathan Wakely <jwakely@redhat.com>
Mon, 4 Oct 2021 13:04:20 +0000 (14:04 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 4 Oct 2021 14:23:28 +0000 (15:23 +0100)
commit22d34a2a50651d01669b6fbcdb9677c18d2197c5
tree98479ac458d4dac2a683cd42f001aff3cc1f6d60
parent728e639d82099035fdfe69b716a54717ae7050e0
libstdc++: Implement P1518R2 for container deduction guides

This implements the C++23 P1518R2 proposal "Stop overconstraining
allocators in container deduction guides" as a fix for C++17 and C++20
too.

The changes allow class template argument deduction to ignore the type
of a constructor argument that initializes an allocator_type parameter
if the type should be deducible only from the other arguments. So for
the constructor vector(const vector&, const allocator_type&) only the
first argument is used for deduction, allowing the second argument to be
anything that is implicitly convertible to argument_type. Previously
deduction would fail or an ill-formed type would be deduced if the
second argument wasn't of type allocator_type.

The unordered containers do not need changes, because their
allocator-extended constructors use the allocator_type alias, which
comes from the dependent base class so is already a non-deduced context.

libstdc++-v3/ChangeLog:

* include/bits/forward_list.h (forward_list): Use non-deduced
context for allocator parameter of allocator-extended copy and
move constructors.
* include/bits/stl_bvector.h (vector<bool>): Likewise.
* include/bits/stl_deque.h (deque): Likewise.
* include/bits/stl_list.h (list): Likewise.
* include/bits/stl_map.h (map): Likewise.
* include/bits/stl_multimap.h (multimap): Likewise.
* include/bits/stl_multiset.h (multiset): Likewise.
* include/bits/stl_set.h (set): Likewise.
* include/bits/stl_vector.h (vector): Likewise.
* include/bits/stl_queue.h (queue, priority_queue): Do not
constrain Allocator template parameter of deduction guides that
have a Container parameter.
* include/bits/stl_stack.h (stack): Likewise.
* include/debug/deque (__gnu_debug::deque): Use non-deduced
context for allocator parameter of allocator-extended copy and
move constructors.
* include/debug/list (__gnu_debug::list): Likewise.
* include/debug/map.h (__gnu_debug::map): Likewise.
* include/debug/multimap.h (__gnu_debug::multimap): Likewise.
* include/debug/multiset.h (__gnu_debug::multiset): Likewise.
* include/debug/set.h (__gnu_debug::set): Likewise.
* include/debug/vector (__gnu_debug::vector): Likewise.
* testsuite/23_containers/deque/cons/deduction.cc: Test class
template argument deduction with non-deduced allocator
arguments.
* testsuite/23_containers/forward_list/cons/deduction.cc:
Likewise.
* testsuite/23_containers/list/cons/deduction.cc: Likewise.
* testsuite/23_containers/map/cons/deduction.cc: Likewise.
* testsuite/23_containers/multimap/cons/deduction.cc: Likewise.
* testsuite/23_containers/multiset/cons/deduction.cc: Likewise.
* testsuite/23_containers/priority_queue/deduction.cc: Likewise.
* testsuite/23_containers/queue/deduction.cc: Likewise.
* testsuite/23_containers/set/cons/deduction.cc: Likewise.
* testsuite/23_containers/stack/deduction.cc: Likewise.
* testsuite/23_containers/unordered_map/cons/deduction.cc:
Likewise.
* testsuite/23_containers/unordered_multimap/cons/deduction.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/cons/deduction.cc:
Likewise.
* testsuite/23_containers/unordered_set/cons/deduction.cc:
Likewise.
* testsuite/23_containers/vector/cons/deduction.cc: Likewise.
33 files changed:
libstdc++-v3/include/bits/forward_list.h
libstdc++-v3/include/bits/stl_bvector.h
libstdc++-v3/include/bits/stl_deque.h
libstdc++-v3/include/bits/stl_list.h
libstdc++-v3/include/bits/stl_map.h
libstdc++-v3/include/bits/stl_multimap.h
libstdc++-v3/include/bits/stl_multiset.h
libstdc++-v3/include/bits/stl_queue.h
libstdc++-v3/include/bits/stl_set.h
libstdc++-v3/include/bits/stl_stack.h
libstdc++-v3/include/bits/stl_vector.h
libstdc++-v3/include/debug/deque
libstdc++-v3/include/debug/list
libstdc++-v3/include/debug/map.h
libstdc++-v3/include/debug/multimap.h
libstdc++-v3/include/debug/multiset.h
libstdc++-v3/include/debug/set.h
libstdc++-v3/include/debug/vector
libstdc++-v3/testsuite/23_containers/deque/cons/deduction.cc
libstdc++-v3/testsuite/23_containers/forward_list/cons/deduction.cc
libstdc++-v3/testsuite/23_containers/list/cons/deduction.cc
libstdc++-v3/testsuite/23_containers/map/cons/deduction.cc
libstdc++-v3/testsuite/23_containers/multimap/cons/deduction.cc
libstdc++-v3/testsuite/23_containers/multiset/cons/deduction.cc
libstdc++-v3/testsuite/23_containers/priority_queue/deduction.cc
libstdc++-v3/testsuite/23_containers/queue/deduction.cc
libstdc++-v3/testsuite/23_containers/set/cons/deduction.cc
libstdc++-v3/testsuite/23_containers/stack/deduction.cc
libstdc++-v3/testsuite/23_containers/unordered_map/cons/deduction.cc
libstdc++-v3/testsuite/23_containers/unordered_multimap/cons/deduction.cc
libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/deduction.cc
libstdc++-v3/testsuite/23_containers/unordered_set/cons/deduction.cc
libstdc++-v3/testsuite/23_containers/vector/cons/deduction.cc