blob: 91bf7e7654e036184932c6fd57121c0d403a562e [file] [log] [blame]
Howard Hinnantc52f43e2010-08-22 00:59:46 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantc52f43e2010-08-22 00:59:46 +00007//
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), "");
Dan Albert1d4a1ed2016-05-25 22:36:09 -070020#if _LIBCPP_STD_VER > 11
Marshall Clowdab89a12013-10-07 23:43:33 +000021 static_assert((std::is_same<std::common_type_t<int>, int>::value), "");
Marshall Clow933afa92013-07-04 00:10:01 +000022 static_assert((std::is_same<std::common_type_t<char>, char>::value), "");
23#endif
Howard Hinnantc52f43e2010-08-22 00:59:46 +000024
Marshall Clowdab89a12013-10-07 23:43:33 +000025 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 Albert1d4a1ed2016-05-25 22:36:09 -070032
Marshall Clowdab89a12013-10-07 23:43:33 +000033 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 Hinnantc52f43e2010-08-22 00:59:46 +000039 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 Albert1d4a1ed2016-05-25 22:36:09 -070041#if _LIBCPP_STD_VER > 11
Marshall Clow933afa92013-07-04 00:10:01 +000042 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 Hinnantc52f43e2010-08-22 00:59:46 +000045
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 Albert1d4a1ed2016-05-25 22:36:09 -070048#if _LIBCPP_STD_VER > 11
Marshall Clow933afa92013-07-04 00:10:01 +000049 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 Hinnantc52f43e2010-08-22 00:59:46 +000052}