[PATCH] D27606: [libcxx] Fix tuple construction/assignment from types derived from tuple/pair/array.
Eric Fiselier via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 9 04:00:12 PST 2016
EricWF created this revision.
EricWF added reviewers: mclow.lists, K-ballo, mpark.
EricWF added a subscriber: cfe-commits.
The standard requires tuple have the following constructors:
tuple(tuple<OtherTypes...> const&);
tuple(tuple<OtherTypes...> &&);
tuple(pair<T1, T2> const&);
tuple(pair<T1, T2> &&);
tuple(array<T, N> const&);
tuple(array<T, N> &&);
However libc++ implements these as a single constructor with the signature:
template <class TupleLike, enable_if_t<__is_tuple_like<TupleLike>::value>>
tuple(TupleLike&&);
This causes the constructor to reject types derived from tuple-like types; Unlike if we had all of the concrete overloads, because they cause the derived->base conversion in the signature.
This patch fixes this issue by detecting derived types and the tuple-like base they are derived from. It does this by creating an overloaded function with signatures for each of tuple/pair/array and checking if the possibly derived type can convert to any of them.
This patch fixes PR17550 <https://llvm.org/bugs/show_bug.cgi?id=17550>
This patch
https://reviews.llvm.org/D27606
Files:
include/__tuple
include/tuple
include/type_traits
test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp
test/std/utilities/tuple/tuple.tuple/tuple.cnstr/derived_from_tuple_like.pass.cpp
test/support/propagate_value_category.hpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27606.80855.patch
Type: text/x-patch
Size: 24947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161209/463b1acb/attachment-0001.bin>
More information about the cfe-commits
mailing list