[libc++] Fix tuple assignment from types derived from a tuple-like
authorLouis Dionne <ldionne@apple.com>
Tue, 31 Jul 2018 15:56:20 +0000 (11:56 -0400)
committerLouis Dionne <ldionne.2@gmail.com>
Mon, 22 Feb 2021 19:52:18 +0000 (14:52 -0500)
commita0839b14df6de99fe29bee7cdfff182d50de665d
tree62981fc220b5fcd6a0c461a00c249037c549a819
parent946a09945f02427c7b2075ae72ea4d77bb1a2a1d
[libc++] Fix tuple assignment from types derived from a tuple-like

The implementation of tuple's constructors and assignment operators
currently diverges from the way the Standard specifies them, which leads
to subtle cases where the behavior is not as specified. In particular, a
class derived from a tuple-like type (e.g. pair) can't be assigned to a
tuple with corresponding members, when it should. This commit re-implements
the assignment operators (BUT NOT THE CONSTRUCTORS) in a way much closer
to the specification to get rid of this bug. Most of the tests have been
stolen from Eric's patch https://reviews.llvm.org/D27606.

As a fly-by improvement, tests for noexcept correctness have been added
to all overloads of operator=. We should tackle the same issue for the
tuple constructors in a future patch - I'm just trying to make progress
on fixing this long-standing bug.

PR17550
rdar://15837420

Differential Revision: https://reviews.llvm.org/D50106
12 files changed:
libcxx/include/tuple
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.assign/array.extension.pass.cpp [new file with mode: 0644]
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp [moved from libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp with 100% similarity]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/laziness.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
libcxx/test/support/propagate_value_category.hpp [new file with mode: 0644]