28 #ifndef VC_TRAITS_IS_IMPLICIT_CAST_ALLOWED_H_
29 #define VC_TRAITS_IS_IMPLICIT_CAST_ALLOWED_H_
31 namespace Vc_VERSIONED_NAMESPACE
35 template <typename From, typename To, bool = std::is_integral<From>::value>
36 struct is_implicit_cast_allowed
37 :
public std::integral_constant<
38 bool, std::is_same<From, To>::value ||
39 (std::is_integral<To>::value &&
40 (std::is_same<typename std::make_unsigned<From>::type, To>::value ||
41 std::is_same<typename std::make_signed<From>::type, To>::value))> {
44 template <
typename From,
typename To>
45 struct is_implicit_cast_allowed<From, To, false> :
public std::is_same<From, To>::type {
48 template <
typename From,
typename To>
49 struct is_implicit_cast_allowed_mask :
public is_implicit_cast_allowed<From, To> {
52 static_assert(is_implicit_cast_allowed<float, float>::value,
"");
53 static_assert(!is_implicit_cast_allowed<float, double>::value,
"");
54 static_assert(is_implicit_cast_allowed< int64_t, uint64_t>::value,
"");
55 static_assert(is_implicit_cast_allowed<uint64_t, int64_t>::value,
"");
56 static_assert(is_implicit_cast_allowed< int32_t, uint32_t>::value,
"");
57 static_assert(is_implicit_cast_allowed<uint32_t, int32_t>::value,
"");
58 static_assert(is_implicit_cast_allowed< int16_t, uint16_t>::value,
"");
59 static_assert(is_implicit_cast_allowed<uint16_t, int16_t>::value,
"");
60 static_assert(is_implicit_cast_allowed< int8_t, uint8_t>::value,
"");
61 static_assert(is_implicit_cast_allowed< uint8_t, int8_t>::value,
"");
66 #endif // VC_TRAITS_IS_IMPLICIT_CAST_ALLOWED_H_