summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2018-01-03 02:32:28 +0000
committerMarshall Clow <mclow.lists@gmail.com>2018-01-03 02:32:28 +0000
commit73d6c99b8bfff9570173cc3a7de5386be0530969 (patch)
tree5276e2d68c0a0828a46cb0f154561fc1b9c452aa /test
parent97adf8a38ed1ddbd3e467ea472daed9cc611f4f3 (diff)
Implement p0258r2: has_unique_object_representations
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@321685 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/std/utilities/meta/meta.unary/meta.unary.prop/has_unique_object_representations.pass.cpp104
1 files changed, 104 insertions, 0 deletions
diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/has_unique_object_representations.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/has_unique_object_representations.pass.cpp
new file mode 100644
index 000000000..e4a3d203c
--- /dev/null
+++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/has_unique_object_representations.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: clang-3, clang-4, clang-5, apple-clang, gcc-4, gcc-5, gcc-6
+
+// type_traits
+
+// has_unique_object_representations
+
+#include <type_traits>
+
+#include "test_macros.h"
+
+template <class T>
+void test_has_unique_object_representations()
+{
+ static_assert( std::has_unique_object_representations<T>::value, "");
+ static_assert( std::has_unique_object_representations<const T>::value, "");
+ static_assert( std::has_unique_object_representations<volatile T>::value, "");
+ static_assert( std::has_unique_object_representations<const volatile T>::value, "");
+
+ static_assert( std::has_unique_object_representations_v<T>, "");
+ static_assert( std::has_unique_object_representations_v<const T>, "");
+ static_assert( std::has_unique_object_representations_v<volatile T>, "");
+ static_assert( std::has_unique_object_representations_v<const volatile T>, "");
+}
+
+template <class T>
+void test_has_not_has_unique_object_representations()
+{
+ static_assert(!std::has_unique_object_representations<T>::value, "");
+ static_assert(!std::has_unique_object_representations<const T>::value, "");
+ static_assert(!std::has_unique_object_representations<volatile T>::value, "");
+ static_assert(!std::has_unique_object_representations<const volatile T>::value, "");
+
+ static_assert(!std::has_unique_object_representations_v<T>, "");
+ static_assert(!std::has_unique_object_representations_v<const T>, "");
+ static_assert(!std::has_unique_object_representations_v<volatile T>, "");
+ static_assert(!std::has_unique_object_representations_v<const volatile T>, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+ virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+ int : 0;
+};
+
+class Abstract
+{
+ virtual ~Abstract() = 0;
+};
+
+struct A
+{
+ ~A();
+ unsigned foo;
+};
+
+struct B
+{
+ char bar;
+ int foo;
+};
+
+
+int main()
+{
+ test_has_not_has_unique_object_representations<void>();
+ test_has_not_has_unique_object_representations<Empty>();
+ test_has_not_has_unique_object_representations<NotEmpty>();
+ test_has_not_has_unique_object_representations<bit_zero>();
+ test_has_not_has_unique_object_representations<Abstract>();
+ test_has_not_has_unique_object_representations<B>();
+
+// I would expect all three of these to have unique representations.
+// I would also expect that there are systems where they do not.
+// test_has_not_has_unique_object_representations<int&>();
+// test_has_not_has_unique_object_representations<int *>();
+// test_has_not_has_unique_object_representations<double>();
+
+
+ test_has_unique_object_representations<unsigned>();
+ test_has_unique_object_representations<Union>();
+ test_has_unique_object_representations<char[3]>();
+ test_has_unique_object_representations<char[]>();
+
+}