1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // type_traits 11 12 // integral_constant 13 14 #include <type_traits> 15 #include <cassert> 16 17 #include "test_macros.h" 18 19 int main() 20 { 21 typedef std::integral_constant<int, 5> _5; 22 static_assert(_5::value == 5, ""); 23 static_assert((std::is_same<_5::value_type, int>::value), ""); 24 static_assert((std::is_same<_5::type, _5>::value), ""); 25 #ifndef _LIBCPP_HAS_NO_CONSTEXPR 26 static_assert((_5() == 5), ""); 27 #else 28 assert(_5() == 5); 29 #endif 30 31 #if TEST_STD_VER > 11 32 static_assert ( _5{}() == 5, "" ); 33 static_assert ( std::true_type{}(), "" ); 34 #endif 35 36 static_assert(std::false_type::value == false, ""); 37 static_assert((std::is_same<std::false_type::value_type, bool>::value), ""); 38 static_assert((std::is_same<std::false_type::type, std::false_type>::value), ""); 39 40 static_assert(std::true_type::value == true, ""); 41 static_assert((std::is_same<std::true_type::value_type, bool>::value), ""); 42 static_assert((std::is_same<std::true_type::type, std::true_type>::value), ""); 43 44 std::false_type f1; 45 std::false_type f2 = f1; 46 assert(!f2); 47 48 std::true_type t1; 49 std::true_type t2 = t1; 50 assert(t2); 51 } 52