diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index d522b29a01d5396eda77b621cd2fc5cf3c2be93b..bbcea859f7553b328873ea1251e2e8ed678d1e0b 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -211,6 +211,14 @@ template <> struct __is_void : public true_type {}; template struct _LIBCPP_VISIBLE is_void : public __is_void::type> {}; +// __is_nullptr_t + +template struct ____is_nullptr_t : public false_type {}; +template <> struct ____is_nullptr_t : public true_type {}; + +template struct _LIBCPP_VISIBLE __is_nullptr_t + : public ____is_nullptr_t::type> {}; + // is_integral template struct __is_integral : public false_type {}; @@ -392,18 +400,17 @@ template struct _LIBCPP_VISIBLE is_arithmetic // is_fundamental template struct _LIBCPP_VISIBLE is_fundamental - : public integral_constant::value || + : public integral_constant::value || + __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {}; -template <> struct _LIBCPP_VISIBLE is_fundamental - : public true_type {}; - // is_scalar template struct _LIBCPP_VISIBLE is_scalar : public integral_constant::value || is_member_pointer<_Tp>::value || is_pointer<_Tp>::value || + __is_nullptr_t<_Tp>::value || is_enum<_Tp>::value > {}; template <> struct _LIBCPP_VISIBLE is_scalar : public true_type {}; diff --git a/libcxx/test/language.support/support.types/nullptr_t.pass.cpp b/libcxx/test/language.support/support.types/nullptr_t.pass.cpp index 1e67faa8b7f6f3f6128008602430ee5ee2d410ab..6c15fefdc4819d09104f29a9f74c1de9eed139c2 100644 --- a/libcxx/test/language.support/support.types/nullptr_t.pass.cpp +++ b/libcxx/test/language.support/support.types/nullptr_t.pass.cpp @@ -41,4 +41,19 @@ int main() assert(!(nullptr != nullptr)); assert(!(nullptr < nullptr)); assert(!(nullptr > nullptr)); + A* a = nullptr; + assert(a == nullptr); + assert(a <= nullptr); + assert(a >= nullptr); + assert(!(a != nullptr)); + assert(!(a < nullptr)); + assert(!(a > nullptr)); + assert(nullptr == a); + assert(nullptr <= a); + assert(nullptr >= a); + assert(!(nullptr != a)); + assert(!(nullptr < a)); + assert(!(nullptr > a)); + std::ptrdiff_t i = reinterpret_cast(nullptr); + assert(i == 0); }