//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11, c++14 // UNSUPPORTED: clang-3, clang-4, clang-5, apple-clang, 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 EmptyUnion {}; struct NonEmptyUnion {int x; unsigned y;}; struct bit_zero { int : 0; }; class Abstract { virtual ~Abstract() = 0; }; struct A { ~A(); unsigned foo; }; struct B { char bar; int foo; }; int main(int, char**) { 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(); 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(); return 0; }