Index: libcxx/include/__utility/declval.h =================================================================== --- libcxx/include/__utility/declval.h +++ libcxx/include/__utility/declval.h @@ -27,7 +27,12 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP template -decltype(std::__declval<_Tp>(0)) declval() _NOEXCEPT; +inline constexpr bool __false = false; + +template +decltype(std::__declval<_Tp>(0)) declval() _NOEXCEPT { + static_assert(__false<_Tp>, "Calling declval is ill-formed, see [declval]/2."); +} _LIBCPP_END_NAMESPACE_STD