diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -550,7 +550,7 @@ // is_same -#if __has_keyword(__is_same) +#if __has_builtin(__is_same) template struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { }; @@ -560,6 +560,16 @@ inline constexpr bool is_same_v = __is_same(_Tp, _Up); #endif +// _IsSame has the same effect as is_same but instantiates fewer types: +// is_same and is_same are guaranteed to be different types, but on supported +// compilers _IsSame and _IsSame may be the same type (namely, false_type). + +template +using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>; + +template +using _IsNotSame = _BoolConstant; + #else template struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {}; @@ -570,26 +580,13 @@ inline constexpr bool is_same_v = is_same<_Tp, _Up>::value; #endif -#endif // __is_same - template -using _IsSame = _BoolConstant< -#ifdef __clang__ - __is_same(_Tp, _Up) -#else - is_same<_Tp, _Up>::value -#endif ->; +using _IsSame = is_same<_Tp, _Up>; template -using _IsNotSame = _BoolConstant< -#ifdef __clang__ - !__is_same(_Tp, _Up) -#else - !is_same<_Tp, _Up>::value -#endif ->; +using _IsNotSame = _BoolConstant::value>; +#endif // __has_builtin(__is_same) template using __test_for_primary_template = __enable_if_t< @@ -602,8 +599,6 @@ struct __two {char __lx[2];}; -// helper class: - // is_const #if __has_keyword(__is_const)