summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2019-07-12 23:01:48 +0000
committerEric Fiselier <eric@efcs.ca>2019-07-12 23:01:48 +0000
commit882fdf68b74d3199cb84b062709b702ed610f547 (patch)
tree9eac114da019a5e0c19d173d975d9730dda50aa8 /libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
parent1dfae6fe505ffedf97e9f36d207cb8bbdc9255d8 (diff)
downloadbcm5719-llvm-882fdf68b74d3199cb84b062709b702ed610f547.tar.gz
bcm5719-llvm-882fdf68b74d3199cb84b062709b702ed610f547.zip
Fix non-conformance it `std::tuple`.
Previously we implemented all one trillion tuple-like constructors using a single generic overload. This worked fairly well, except that it differed in behavior from the standard version because it didn't consider both T&& and T const&. This was observable for certain types. This patch addresses that issue by splitting the generic constructor in two. We now provide both T&& and T const& versions of the tuple-like constructors (sort of). llvm-svn: 365973
Diffstat (limited to 'libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp')
-rw-r--r--libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
index 41f73328ab7..89f67a227bd 100644
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
+++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
@@ -31,6 +31,15 @@ struct Implicit {
Implicit(int x) : value(x) {}
};
+struct ExplicitTwo {
+ ExplicitTwo() {}
+ ExplicitTwo(ExplicitTwo const&) {}
+ ExplicitTwo(ExplicitTwo &&) {}
+
+ template <class T, class = typename std::enable_if<!std::is_same<T, ExplicitTwo>::value>::type>
+ explicit ExplicitTwo(T) {}
+};
+
struct B
{
int id_;
@@ -136,6 +145,13 @@ int main(int, char**)
std::tuple<Implicit> t2 = t1;
assert(std::get<0>(t2).value == 42);
}
+ {
+ static_assert(std::is_convertible<ExplicitTwo&&, ExplicitTwo>::value, "");
+ static_assert(std::is_convertible<std::tuple<ExplicitTwo&&>&&, const std::tuple<ExplicitTwo>&>::value, "");
+ ExplicitTwo e;
+ std::tuple<ExplicitTwo> t = std::tuple<ExplicitTwo&&>(std::move(e));
+ ((void)t);
+ }
return 0;
}
OpenPOWER on IntegriCloud