1505ceacdSEric Fiselier //===----------------------------------------------------------------------===//
2505ceacdSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6505ceacdSEric Fiselier //
7505ceacdSEric Fiselier //===----------------------------------------------------------------------===//
8505ceacdSEric Fiselier
9505ceacdSEric Fiselier // type_traits
10505ceacdSEric Fiselier
11505ceacdSEric Fiselier // integral_constant
12505ceacdSEric Fiselier
13505ceacdSEric Fiselier #include <type_traits>
14505ceacdSEric Fiselier #include <cassert>
15505ceacdSEric Fiselier
160f901c7eSStephan T. Lavavej #include "test_macros.h"
170f901c7eSStephan T. Lavavej
main(int,char **)18*2df59c50SJF Bastien int main(int, char**)
19505ceacdSEric Fiselier {
20505ceacdSEric Fiselier typedef std::integral_constant<int, 5> _5;
21505ceacdSEric Fiselier static_assert(_5::value == 5, "");
22505ceacdSEric Fiselier static_assert((std::is_same<_5::value_type, int>::value), "");
23505ceacdSEric Fiselier static_assert((std::is_same<_5::type, _5>::value), "");
2495f8e6aaSEric Fiselier #if TEST_STD_VER >= 11
25505ceacdSEric Fiselier static_assert((_5() == 5), "");
26505ceacdSEric Fiselier #endif
2795f8e6aaSEric Fiselier assert(_5() == 5);
2895f8e6aaSEric Fiselier
29505ceacdSEric Fiselier
300f901c7eSStephan T. Lavavej #if TEST_STD_VER > 11
31505ceacdSEric Fiselier static_assert ( _5{}() == 5, "" );
32505ceacdSEric Fiselier static_assert ( std::true_type{}(), "" );
33505ceacdSEric Fiselier #endif
34505ceacdSEric Fiselier
35505ceacdSEric Fiselier static_assert(std::false_type::value == false, "");
36505ceacdSEric Fiselier static_assert((std::is_same<std::false_type::value_type, bool>::value), "");
37505ceacdSEric Fiselier static_assert((std::is_same<std::false_type::type, std::false_type>::value), "");
38505ceacdSEric Fiselier
39505ceacdSEric Fiselier static_assert(std::true_type::value == true, "");
40505ceacdSEric Fiselier static_assert((std::is_same<std::true_type::value_type, bool>::value), "");
41505ceacdSEric Fiselier static_assert((std::is_same<std::true_type::type, std::true_type>::value), "");
42505ceacdSEric Fiselier
43505ceacdSEric Fiselier std::false_type f1;
44505ceacdSEric Fiselier std::false_type f2 = f1;
45505ceacdSEric Fiselier assert(!f2);
46505ceacdSEric Fiselier
47505ceacdSEric Fiselier std::true_type t1;
48505ceacdSEric Fiselier std::true_type t2 = t1;
49505ceacdSEric Fiselier assert(t2);
50*2df59c50SJF Bastien
51*2df59c50SJF Bastien return 0;
52505ceacdSEric Fiselier }
53