Libstdc++ Constrains Tuple Move Constructor for C++20
The libstdc++ `std::tuple` move constructor is now constrained in C++20 mode, ensuring it's only available when all elements are move-constructible.
The std::tuple move constructor in libstdc++ is now constrained in C++20 mode. This ensures that the move constructor is only available when all element types within the tuple are move-constructible. Before this change, the move constructor could be implicitly defined as deleted even if non-move-constructible types were present, due to an unconstrained constructor in the underlying implementation. The constraint is implemented using a requires-clause.
In Details
This commit addresses PR78302 and PR71301 by adding a requires-clause to the tuple(tuple&&) constructor in <tuple>. This constraint, only applied for C++20 and later, ensures the move constructor is properly defined as deleted when element types are not move-constructible, aligning with LWG 2899's modifications to the C++ standard.
For Context
A std::tuple is a container that groups together elements of different types. A move constructor creates a new object by transferring ownership of resources from an existing object. This commit constrains the move constructor of std::tuple in C++20, ensuring it is only available when all elements within the tuple are move-constructible. This prevents unexpected behavior when moving tuples containing types that cannot be moved.