Implement LWG 2905 changes to constrain unique_ptr constructors

Programming / Compilers / GCC - redi [138bc75d-0d04-0410-961f-82ee72b054a4] - 11 September 2018 10:55 EDT

LWG DR 2905 says that is_constructible_v, P, D const &> should be false when D is not copy constructible. This commit implements the changes from the DR and simplifies the signatures as per https://github.com/cplusplus/draft/issues/1530

- include/bits/unique_ptr.h (__uniq_ptr_impl): Add assertions to check deleter type. (unique_ptr::unique_ptr(pointer, const deleter_type&)): Add copy constructible constraint. (unique_ptr::unique_ptr(pointer, deleter_type&&)): Disable for deleters of reference type and add move constructible constraint. (unique_ptr::unique_ptr(pointer, remove_reference_t&&)): Disable for deleters of non-reference type. Define as deleted. (unique_ptr): Likewise.
- testsuite/20_util/unique_ptr/assign/48635_neg.cc: Replace dg-error directives with unstable line numbers with dg-prune-output.
- testsuite/20_util/unique_ptr/cons/cv_qual_neg.cc: Likewise.
- testsuite/20_util/unique_ptr/cons/lwg2905.cc: New test.
- testsuite/20_util/unique_ptr/specialized_algorithms/swap_cxx17.cc: Make deleter types invocable.

199f729ee3a Implement LWG 2905 changes to constrain unique_ptr constructors
libstdc++-v3/ChangeLog | 19 +++++
libstdc++-v3/include/bits/unique_ptr.h | 90 +++++++++++++---------
.../20_util/unique_ptr/assign/48635_neg.cc | 4 +-
.../20_util/unique_ptr/cons/cv_qual_neg.cc | 2 +-
.../testsuite/20_util/unique_ptr/cons/lwg2905.cc | 78 +++++++++++++++++++
.../specialized_algorithms/swap_cxx17.cc | 9 ++-
6 files changed, 160 insertions(+), 42 deletions(-)

Upstream: gcc.gnu.org


  • Share