Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / meta / meta.unary / meta.unary.prop / is_trivial.pass.cpp
blob8bb1b7c9b09dde24d7eab62e22fa273672731903
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // type_traits
11 // is_trivial
13 #include <type_traits>
14 #include "test_macros.h"
16 template <class T>
17 void test_is_trivial()
19 static_assert( std::is_trivial<T>::value, "");
20 static_assert( std::is_trivial<const T>::value, "");
21 static_assert( std::is_trivial<volatile T>::value, "");
22 static_assert( std::is_trivial<const volatile T>::value, "");
23 #if TEST_STD_VER > 14
24 static_assert( std::is_trivial_v<T>, "");
25 static_assert( std::is_trivial_v<const T>, "");
26 static_assert( std::is_trivial_v<volatile T>, "");
27 static_assert( std::is_trivial_v<const volatile T>, "");
28 #endif
31 template <class T>
32 void test_is_not_trivial()
34 static_assert(!std::is_trivial<T>::value, "");
35 static_assert(!std::is_trivial<const T>::value, "");
36 static_assert(!std::is_trivial<volatile T>::value, "");
37 static_assert(!std::is_trivial<const volatile T>::value, "");
38 #if TEST_STD_VER > 14
39 static_assert(!std::is_trivial_v<T>, "");
40 static_assert(!std::is_trivial_v<const T>, "");
41 static_assert(!std::is_trivial_v<volatile T>, "");
42 static_assert(!std::is_trivial_v<const volatile T>, "");
43 #endif
46 struct A {};
48 class B
50 public:
51 B();
54 int main(int, char**)
56 test_is_trivial<int> ();
57 test_is_trivial<A> ();
59 test_is_not_trivial<int&> ();
60 test_is_not_trivial<volatile int&> ();
61 test_is_not_trivial<B> ();
63 return 0;