[libc++] P2321R2 section [tuple.tuple]. Adding C++23 constructors, assignment operato...
authorHui Xie <hui.xie1990@gmail.com>
Thu, 12 May 2022 12:23:11 +0000 (13:23 +0100)
committerHui Xie <hui.xie1990@gmail.com>
Thu, 23 Jun 2022 20:28:57 +0000 (21:28 +0100)
commit95733a55b986e73f4d8f5314e0d4557d8ae0b226
treeab08243627cbcca1b0e91b1ffa3cd706d7e21229
parent23d6cde14de352e05c66ae34cd237e3a7a8955d1
[libc++] P2321R2 section [tuple.tuple]. Adding C++23 constructors, assignment operators and swaps to `tuple`

1. for constructors that takes cvref variation of tuple<UTypes...>, there
used to be two SFINAE helper _EnableCopyFromOtherTuple,
_EnableMoveFromOtherTuple. And the implementations of these two helpers
seem to slightly differ from the spec. But now, we need 4 variations.
Instead of adding another two, this change refactored it to a single one
_EnableCtrFromUTypesTuple, which directly maps to the spec without
changing the C++11 behaviour. However, we need the helper __copy_cvref_t
to get the type of std::get<i>(cvref tuple<Utypes...>) for different
cvref, so I made __copy_cvref_t to be available in C++11.

2. for constructors that takes variations of std::pair, there used to be
four helpers _EnableExplicitCopyFromPair, _EnableImplicitCopyFromPair,
_EnableImplicitMoveFromPair, _EnableExplicitMoveFromPair. Instead of
adding another four, this change refactored into two helper
_EnableCtrFromPair and _BothImplicitlyConvertible. This also removes the
need to use _nat

3. for const member assignment operator, since the requirement is very
simple, I haven't refactored the old code but instead directly adding
the new c++23 code.

4. for const swap, I pretty much copy pasted the non-const version to make
these overloads look consistent

5. while doing these change, I found two of the old constructors wasn't
marked constexpr for C++20 but they should. fixed them and added unit
tests

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D116621
25 files changed:
libcxx/include/tuple
libcxx/include/type_traits
libcxx/test/libcxx/utilities/meta/meta_base.pass.cpp
libcxx/test/std/ranges/range.adaptors/range.zip/range.concept.compile.pass.cpp
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_convert_copy.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_convert_move.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_copy.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_move.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair_copy.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair_move.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/types.h [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_move_pair.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_const_move.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_non_const_copy.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_non_const_pair.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_move_pair.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_const_move.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_non_const_copy.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_types.h [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/non_const_pair.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.special/non_member_swap_const.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.swap/member_swap_const.pass.cpp [new file with mode: 0644]