From 73d6c99b8bfff9570173cc3a7de5386be0530969 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 3 Jan 2018 02:32:28 +0000 Subject: Implement p0258r2: has_unique_object_representations git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@321685 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../has_unique_object_representations.pass.cpp | 104 +++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.prop/has_unique_object_representations.pass.cpp (limited to 'test') 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 + +#include "test_macros.h" + +template +void test_has_unique_object_representations() +{ + static_assert( std::has_unique_object_representations::value, ""); + static_assert( std::has_unique_object_representations::value, ""); + static_assert( std::has_unique_object_representations::value, ""); + static_assert( std::has_unique_object_representations::value, ""); + + static_assert( std::has_unique_object_representations_v, ""); + static_assert( std::has_unique_object_representations_v, ""); + static_assert( std::has_unique_object_representations_v, ""); + static_assert( std::has_unique_object_representations_v, ""); +} + +template +void test_has_not_has_unique_object_representations() +{ + static_assert(!std::has_unique_object_representations::value, ""); + static_assert(!std::has_unique_object_representations::value, ""); + static_assert(!std::has_unique_object_representations::value, ""); + static_assert(!std::has_unique_object_representations::value, ""); + + static_assert(!std::has_unique_object_representations_v, ""); + static_assert(!std::has_unique_object_representations_v, ""); + static_assert(!std::has_unique_object_representations_v, ""); + static_assert(!std::has_unique_object_representations_v, ""); +} + +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(); + test_has_not_has_unique_object_representations(); + test_has_not_has_unique_object_representations(); + test_has_not_has_unique_object_representations(); + test_has_not_has_unique_object_representations(); + test_has_not_has_unique_object_representations(); + +// 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(); +// test_has_not_has_unique_object_representations(); +// test_has_not_has_unique_object_representations(); + + + test_has_unique_object_representations(); + test_has_unique_object_representations(); + test_has_unique_object_representations(); + test_has_unique_object_representations(); + +} -- cgit v1.2.3