Index: include/type_traits =================================================================== --- include/type_traits +++ include/type_traits @@ -4711,12 +4711,15 @@ #ifdef _LIBCPP_UNDERLYING_TYPE -template +template ::value> struct underlying_type { typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type; }; +template +struct underlying_type<_Tp, false> {}; + #if _LIBCPP_STD_VER > 11 template using underlying_type_t = typename underlying_type<_Tp>::type; #endif Index: test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp =================================================================== --- test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp +++ test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp @@ -27,6 +27,15 @@ enum F { W = UINT_MAX }; #endif // TEST_UNSIGNED_UNDERLYING_TYPE +#if TEST_STD_VER > 17 +template +std::enable_if_t< + std::is_same_v, int> +> test_sfinae(T t); + +void test_sfinae(int) { return; } +#endif // TEST_STD_VER > 17 + int main(int, char**) { static_assert((std::is_same::type, int>::value), @@ -52,6 +61,10 @@ static_assert((std::is_same, char>::value), ""); #endif // TEST_STD_VER > 11 #endif // TEST_STD_VER >= 11 + +#if TEST_STD_VER > 17 + test_sfinae(0); +#endif // TEST_STD_VER > 17 return 0; }