Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // type_traits |
| 11 | |
| 12 | // common_type |
| 13 | |
| 14 | #include <type_traits> |
| 15 | |
| 16 | int 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), ""); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 20 | #if _LIBCPP_STD_VER > 11 |
Marshall Clow | dab89a1 | 2013-10-07 23:43:33 +0000 | [diff] [blame] | 21 | static_assert((std::is_same<std::common_type_t<int>, int>::value), ""); |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 22 | static_assert((std::is_same<std::common_type_t<char>, char>::value), ""); |
| 23 | #endif |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 24 | |
Marshall Clow | dab89a1 | 2013-10-07 23:43:33 +0000 | [diff] [blame] | 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), ""); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 32 | |
Marshall Clow | dab89a1 | 2013-10-07 23:43:33 +0000 | [diff] [blame] | 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 | |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 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), ""); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 41 | #if _LIBCPP_STD_VER > 11 |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 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 |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 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), ""); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 48 | #if _LIBCPP_STD_VER > 11 |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 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 |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 52 | } |