summaryrefslogtreecommitdiffstats
path: root/libcxx/test/support
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-10-16 02:51:50 +0000
committerEric Fiselier <eric@efcs.ca>2016-10-16 02:51:50 +0000
commit50253ed1c67b75c71c8ec2d24ed915c032b11822 (patch)
tree95aa7eb8def3b368a026bf4ff96322688bad8582 /libcxx/test/support
parent9c737fddba93bce4127dbed4fa2a4440414c1afb (diff)
downloadbcm5719-llvm-50253ed1c67b75c71c8ec2d24ed915c032b11822.tar.gz
bcm5719-llvm-50253ed1c67b75c71c8ec2d24ed915c032b11822.zip
Update issue status for LWG 2744
llvm-svn: 284322
Diffstat (limited to 'libcxx/test/support')
-rw-r--r--libcxx/test/support/any_helpers.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/libcxx/test/support/any_helpers.h b/libcxx/test/support/any_helpers.h
index ae332d5e0a5..a720ecd7c82 100644
--- a/libcxx/test/support/any_helpers.h
+++ b/libcxx/test/support/any_helpers.h
@@ -59,21 +59,30 @@ void assertEmpty(std::any const& a) {
assert(any_cast<LastType const>(&a) == nullptr);
}
+template <class Type>
+constexpr auto has_value_member(int) -> decltype(std::declval<Type&>().value, true)
+{ return true; }
+template <class> constexpr bool has_value_member(long) { return false; }
+
+
// Assert that an 'any' object stores the specified 'Type' and 'value'.
template <class Type>
-void assertContains(std::any const& a, int value = 1) {
+std::enable_if_t<has_value_member<Type>(0)>
+assertContains(std::any const& a, int value) {
assert(a.has_value());
assert(containsType<Type>(a));
assert(std::any_cast<Type const &>(a).value == value);
}
-template <>
-void assertContains<int>(std::any const& a, int value) {
+template <class Type, class Value>
+std::enable_if_t<!has_value_member<Type>(0)>
+assertContains(std::any const& a, Value value) {
assert(a.has_value());
- assert(containsType<int>(a));
- assert(std::any_cast<int const &>(a) == value);
+ assert(containsType<Type>(a));
+ assert(std::any_cast<Type const &>(a) == value);
}
+
// Modify the value of a "test type" stored within an any to the specified
// 'value'.
template <class Type>
OpenPOWER on IntegriCloud