//===- TypeTraitsTest.cpp -------------------------------------------------===// // // 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 // //===----------------------------------------------------------------------===// #include "llvm/Support/type_traits.h" #include "gtest/gtest.h" namespace { // Compile-time tests using static assert. namespace triviality { // Helper for compile time checking trivially copy constructible and trivially // move constructible type traits. template void TrivialityTester() { static_assert(llvm::is_trivially_copy_constructible::value == IsTriviallyCopyConstructible, "Mismatch in expected trivial copy construction!"); static_assert(llvm::is_trivially_move_constructible::value == IsTriviallyMoveConstructible, "Mismatch in expected trivial move construction!"); #if defined(_LIBCPP_VERSION) || defined(_MSC_VER) // On compilers with support for the standard traits, make sure they agree. static_assert(std::is_trivially_copy_constructible::value == IsTriviallyCopyConstructible, "Mismatch in expected trivial copy construction!"); static_assert(std::is_trivially_move_constructible::value == IsTriviallyMoveConstructible, "Mismatch in expected trivial move construction!"); #endif } template void TrivialityTester(); template void TrivialityTester(); template void TrivialityTester(); template void TrivialityTester(); struct X {}; struct Y { Y(const Y &); }; struct Z { Z(const Z &); Z(Z &&); }; struct A { A(const A &) = default; A(A &&); }; struct B { B(const B &); B(B &&) = default; }; template void TrivialityTester(); template void TrivialityTester(); template void TrivialityTester(); template void TrivialityTester(); template void TrivialityTester(); template void TrivialityTester(); template void TrivialityTester(); template void TrivialityTester(); template void TrivialityTester(); template void TrivialityTester(); template void TrivialityTester(); TEST(Triviality, Tester) { TrivialityTester(); TrivialityTester(); TrivialityTester(); TrivialityTester(); TrivialityTester(); TrivialityTester(); TrivialityTester(); TrivialityTester(); TrivialityTester(); TrivialityTester(); TrivialityTester(); TrivialityTester(); TrivialityTester(); TrivialityTester(); TrivialityTester(); } } // namespace triviality } // end anonymous namespace