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 //===----------------------------------------------------------------------===//
8
9 // type_traits
10
11 // integral_constant
12
13 #include <type_traits>
14 #include <cassert>
15
16 #include "test_macros.h"
17
main(int,char **)18 int main(int, char**)
19 {
20 typedef std::integral_constant<int, 5> _5;
21 static_assert(_5::value == 5, "");
22 static_assert((std::is_same<_5::value_type, int>::value), "");
23 static_assert((std::is_same<_5::type, _5>::value), "");
24 #if TEST_STD_VER >= 11
25 static_assert((_5() == 5), "");
26 #endif
27 assert(_5() == 5);
28
29
30 #if TEST_STD_VER > 11
31 static_assert ( _5{}() == 5, "" );
32 static_assert ( std::true_type{}(), "" );
33 #endif
34
35 static_assert(std::false_type::value == false, "");
36 static_assert((std::is_same<std::false_type::value_type, bool>::value), "");
37 static_assert((std::is_same<std::false_type::type, std::false_type>::value), "");
38
39 static_assert(std::true_type::value == true, "");
40 static_assert((std::is_same<std::true_type::value_type, bool>::value), "");
41 static_assert((std::is_same<std::true_type::type, std::true_type>::value), "");
42
43 std::false_type f1;
44 std::false_type f2 = f1;
45 assert(!f2);
46
47 std::true_type t1;
48 std::true_type t2 = t1;
49 assert(t2);
50
51 return 0;
52 }
53