Bug 953296 - Implement mozilla::NullptrT as a typedef to use to accept nullptr values. Also add mozilla::IsNullPointer<T>, a trait for detecting *only* true nullptr (emulated nullptr [__null] used by gcc 4.4/4.5 isn't true nullptr). r=ehsan
Generally, if you want a decltype(nullptr)-based overload, you should use SFINAE and IsNullPointer. (Examples are provided in NullPtr.h comments.) The problem is NullptrT matches far more than just __null as emulated nullptr for gcc 4.4/4.5 overloading purposes. This problem is unavoidable without true nullptr. Currently, the only valid use for NullptrT is believed to be in operator overloads. All existing nullptr-overloading code has been rewritten to use the appropriate technique for the situation, and MOZ_HAVE_CXX11_NULLPTR is no longer an API.
This commit is contained in:
@@ -100,24 +100,9 @@ class autoJArray {
|
||||
arr = other.arr;
|
||||
length = other.length;
|
||||
}
|
||||
#if defined(MOZ_HAVE_CXX11_NULLPTR)
|
||||
# if defined(__clang__) || defined(_STLPORT_VERSION)
|
||||
// clang on OS X 10.7 and Android's STLPort do not have std::nullptr_t
|
||||
typedef decltype(nullptr) jArray_nullptr_t;
|
||||
# else
|
||||
// decltype(nullptr) does not evaluate to std::nullptr_t on GCC 4.6.3
|
||||
typedef std::nullptr_t jArray_nullptr_t;
|
||||
# endif
|
||||
#elif defined(__GNUC__)
|
||||
typedef void* jArray_nullptr_t;
|
||||
#elif defined(_WIN64)
|
||||
typedef uint64_t jArray_nullptr_t;
|
||||
#else
|
||||
typedef uint32_t jArray_nullptr_t;
|
||||
#endif
|
||||
void operator=(jArray_nullptr_t zero) {
|
||||
void operator=(mozilla::NullptrT n) {
|
||||
// Make assigning null to an array in Java delete the buffer in C++
|
||||
// MSVC10 does not allow asserting that zero is null.
|
||||
MOZ_ASSERT(n == nullptr);
|
||||
delete[] arr;
|
||||
arr = nullptr;
|
||||
length = 0;
|
||||
|
||||
Reference in New Issue
Block a user