[cfe-commits] [libcxx] r127338 - in /libcxx/trunk: include/type_traits test/language.support/support.types/nullptr_t.pass.cpp
Howard Hinnant
hhinnant at apple.com
Wed Mar 9 09:17:06 PST 2011
Author: hhinnant
Date: Wed Mar 9 11:17:06 2011
New Revision: 127338
URL: http://llvm.org/viewvc/llvm-project?rev=127338&view=rev
Log:
Corrected const-correctness on nullptr type_traits, and beefed up the test for nullptr_t.
Modified:
libcxx/trunk/include/type_traits
libcxx/trunk/test/language.support/support.types/nullptr_t.pass.cpp
Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=127338&r1=127337&r2=127338&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Wed Mar 9 11:17:06 2011
@@ -211,6 +211,14 @@
template <class _Tp> struct _LIBCPP_VISIBLE is_void
: public __is_void<typename remove_cv<_Tp>::type> {};
+// __is_nullptr_t
+
+template <class _Tp> struct ____is_nullptr_t : public false_type {};
+template <> struct ____is_nullptr_t<nullptr_t> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_VISIBLE __is_nullptr_t
+ : public ____is_nullptr_t<typename remove_cv<_Tp>::type> {};
+
// is_integral
template <class _Tp> struct __is_integral : public false_type {};
@@ -392,18 +400,17 @@
// is_fundamental
template <class _Tp> struct _LIBCPP_VISIBLE is_fundamental
- : public integral_constant<bool, is_void<_Tp>::value ||
+ : public integral_constant<bool, is_void<_Tp>::value ||
+ __is_nullptr_t<_Tp>::value ||
is_arithmetic<_Tp>::value> {};
-template <> struct _LIBCPP_VISIBLE is_fundamental<nullptr_t>
- : public true_type {};
-
// is_scalar
template <class _Tp> struct _LIBCPP_VISIBLE is_scalar
: public integral_constant<bool, is_arithmetic<_Tp>::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<nullptr_t> : public true_type {};
Modified: libcxx/trunk/test/language.support/support.types/nullptr_t.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/language.support/support.types/nullptr_t.pass.cpp?rev=127338&r1=127337&r2=127338&view=diff
==============================================================================
--- libcxx/trunk/test/language.support/support.types/nullptr_t.pass.cpp (original)
+++ libcxx/trunk/test/language.support/support.types/nullptr_t.pass.cpp Wed Mar 9 11:17:06 2011
@@ -41,4 +41,19 @@
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<std::ptrdiff_t>(nullptr);
+ assert(i == 0);
}
More information about the cfe-commits
mailing list