]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: fix is_default_constructible for hash containers [PR 100863]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 20 Jul 2021 14:20:41 +0000 (15:20 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 20 Jul 2021 15:22:26 +0000 (16:22 +0100)
commit89ec3b67dbe856a447d068b053bc19559f136f43
tree095bc49b129d27b0523b87be0e941583a56a020e
parent1ef9b135793a528c05c4a3e22649744955aa2dfb
libstdc++: fix is_default_constructible for hash containers [PR 100863]

The recent change to _Hashtable_ebo_helper for this PR broke the
is_default_constructible trait for a hash container with a non-default
constructible allocator. That happens because the constructor needs to
be user-provided in order to initialize the member, and so is not
defined as deleted when the type is not default constructible.

By making _Hashtable derive from _Enable_special_members we can ensure
that the default constructor for the std::unordered_xxx containers is
deleted when it would be ill-formed. This makes the trait give the
correct answer.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/100863
* include/bits/hashtable.h (_Hashtable): Conditionally delete
default constructor by deriving from _Enable_special_members.
* testsuite/23_containers/unordered_map/cons/default.cc: New test.
* testsuite/23_containers/unordered_set/cons/default.cc: New test.
libstdc++-v3/include/bits/hashtable.h
libstdc++-v3/testsuite/23_containers/unordered_map/cons/default.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/cons/default.cc [new file with mode: 0644]