common_type.pass.cpp revision dab89a1412fbb013d492c32387cf10fa67cd7981
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// common_type 13 14#include <type_traits> 15 16int main() 17{ 18 static_assert((std::is_same<std::common_type<int>::type, int>::value), ""); 19 static_assert((std::is_same<std::common_type<char>::type, char>::value), ""); 20#if _LIBCPP_STD_VER > 11 21 static_assert((std::is_same<std::common_type_t<int>, int>::value), ""); 22 static_assert((std::is_same<std::common_type_t<char>, char>::value), ""); 23#endif 24 25 static_assert((std::is_same<std::common_type< int>::type, int>::value), ""); 26 static_assert((std::is_same<std::common_type<const int>::type, int>::value), ""); 27 static_assert((std::is_same<std::common_type< volatile int>::type, int>::value), ""); 28 static_assert((std::is_same<std::common_type<const volatile int>::type, int>::value), ""); 29 30 static_assert((std::is_same<std::common_type<int, int>::type, int>::value), ""); 31 static_assert((std::is_same<std::common_type<int, const int>::type, int>::value), ""); 32 33 static_assert((std::is_same<std::common_type<long, const int>::type, long>::value), ""); 34 static_assert((std::is_same<std::common_type<const long, int>::type, long>::value), ""); 35 static_assert((std::is_same<std::common_type<long, volatile int>::type, long>::value), ""); 36 static_assert((std::is_same<std::common_type<volatile long, int>::type, long>::value), ""); 37 static_assert((std::is_same<std::common_type<const long, const int>::type, long>::value), ""); 38 39 static_assert((std::is_same<std::common_type<double, char>::type, double>::value), ""); 40 static_assert((std::is_same<std::common_type<short, char>::type, int>::value), ""); 41#if _LIBCPP_STD_VER > 11 42 static_assert((std::is_same<std::common_type_t<double, char>, double>::value), ""); 43 static_assert((std::is_same<std::common_type_t<short, char>, int>::value), ""); 44#endif 45 46 static_assert((std::is_same<std::common_type<double, char, long long>::type, double>::value), ""); 47 static_assert((std::is_same<std::common_type<unsigned, char, long long>::type, long long>::value), ""); 48#if _LIBCPP_STD_VER > 11 49 static_assert((std::is_same<std::common_type_t<double, char, long long>, double>::value), ""); 50 static_assert((std::is_same<std::common_type_t<unsigned, char, long long>, long long>::value), ""); 51#endif 52} 53