ICU-20265 Use noexcept instead of throw() in C++ >= 11.
- Adds note directing users of U_NO_THROW to U_NOEXCEPT.
diff --git a/icu4c/source/common/cmemory.h b/icu4c/source/common/cmemory.h
index 5c48547..f121bcb 100644
--- a/icu4c/source/common/cmemory.h
+++ b/icu4c/source/common/cmemory.h
@@ -281,10 +281,10 @@
class MaybeStackArray {
public:
// No heap allocation. Use only on the stack.
- static void* U_EXPORT2 operator new(size_t) U_NO_THROW = delete;
- static void* U_EXPORT2 operator new[](size_t) U_NO_THROW = delete;
+ static void* U_EXPORT2 operator new(size_t) U_NOEXCEPT = delete;
+ static void* U_EXPORT2 operator new[](size_t) U_NOEXCEPT = delete;
#if U_HAVE_PLACEMENT_NEW
- static void* U_EXPORT2 operator new(size_t, void*) U_NO_THROW = delete;
+ static void* U_EXPORT2 operator new(size_t, void*) U_NOEXCEPT = delete;
#endif
/**
@@ -496,10 +496,10 @@
class MaybeStackHeaderAndArray {
public:
// No heap allocation. Use only on the stack.
- static void* U_EXPORT2 operator new(size_t) U_NO_THROW = delete;
- static void* U_EXPORT2 operator new[](size_t) U_NO_THROW = delete;
+ static void* U_EXPORT2 operator new(size_t) U_NOEXCEPT = delete;
+ static void* U_EXPORT2 operator new[](size_t) U_NOEXCEPT = delete;
#if U_HAVE_PLACEMENT_NEW
- static void* U_EXPORT2 operator new(size_t, void*) U_NO_THROW = delete;
+ static void* U_EXPORT2 operator new(size_t, void*) U_NOEXCEPT = delete;
#endif
/**
diff --git a/icu4c/source/common/unicode/uobject.h b/icu4c/source/common/unicode/uobject.h
index c42c720..c2663eb 100644
--- a/icu4c/source/common/unicode/uobject.h
+++ b/icu4c/source/common/unicode/uobject.h
@@ -20,6 +20,7 @@
#define __UOBJECT_H__
#include "unicode/utypes.h"
+#include "unicode/platform.h"
/**
* \file
@@ -28,7 +29,9 @@
/**
* \def U_NO_THROW
- * Define this to define the throw() specification so
+ * Since ICU 64, use U_NOEXCEPT instead.
+ *
+ * Previously, define this to define the throw() specification so
* certain functions do not throw any exceptions
*
* UMemory operator new methods should have the throw() specification
@@ -37,7 +40,7 @@
* constructor is still called, and if the constructor references member
* data, (which it typically does), the result is a segmentation violation.
*
- * @stable ICU 4.2
+ * @stable ICU 4.2. Since ICU 64, Use U_NOEXCEPT instead. See ICU-20422.
*/
#ifndef U_NO_THROW
#define U_NO_THROW throw()
@@ -125,14 +128,14 @@
* for ICU4C C++ classes
* @stable ICU 2.4
*/
- static void * U_EXPORT2 operator new(size_t size) U_NO_THROW;
+ static void * U_EXPORT2 operator new(size_t size) U_NOEXCEPT;
/**
* Override for ICU4C C++ memory management.
* See new().
* @stable ICU 2.4
*/
- static void * U_EXPORT2 operator new[](size_t size) U_NO_THROW;
+ static void * U_EXPORT2 operator new[](size_t size) U_NOEXCEPT;
/**
* Override for ICU4C C++ memory management.
@@ -142,14 +145,14 @@
* for ICU4C C++ classes
* @stable ICU 2.4
*/
- static void U_EXPORT2 operator delete(void *p) U_NO_THROW;
+ static void U_EXPORT2 operator delete(void *p) U_NOEXCEPT;
/**
* Override for ICU4C C++ memory management.
* See delete().
* @stable ICU 2.4
*/
- static void U_EXPORT2 operator delete[](void *p) U_NO_THROW;
+ static void U_EXPORT2 operator delete[](void *p) U_NOEXCEPT;
#if U_HAVE_PLACEMENT_NEW
/**
@@ -157,14 +160,14 @@
* See new().
* @stable ICU 2.6
*/
- static inline void * U_EXPORT2 operator new(size_t, void *ptr) U_NO_THROW { return ptr; }
+ static inline void * U_EXPORT2 operator new(size_t, void *ptr) U_NOEXCEPT { return ptr; }
/**
* Override for ICU4C C++ memory management for STL.
* See delete().
* @stable ICU 2.6
*/
- static inline void U_EXPORT2 operator delete(void *, void *) U_NO_THROW {}
+ static inline void U_EXPORT2 operator delete(void *, void *) U_NOEXCEPT {}
#endif /* U_HAVE_PLACEMENT_NEW */
#if U_HAVE_DEBUG_LOCATION_NEW
/**
@@ -174,7 +177,7 @@
* @param file The file where the allocation was requested
* @param line The line where the allocation was requested
*/
- static void * U_EXPORT2 operator new(size_t size, const char* file, int line) U_NO_THROW;
+ static void * U_EXPORT2 operator new(size_t size, const char* file, int line) U_NOEXCEPT;
/**
* This method provides a matching delete for the MFC debug new
*
@@ -182,7 +185,7 @@
* @param file The file where the allocation was requested
* @param line The line where the allocation was requested
*/
- static void U_EXPORT2 operator delete(void* p, const char* file, int line) U_NO_THROW;
+ static void U_EXPORT2 operator delete(void* p, const char* file, int line) U_NOEXCEPT;
#endif /* U_HAVE_DEBUG_LOCATION_NEW */
#endif /* U_OVERRIDE_CXX_ALLOCATION */
diff --git a/icu4c/source/common/uobject.cpp b/icu4c/source/common/uobject.cpp
index 1133dd9..e222b2c 100644
--- a/icu4c/source/common/uobject.cpp
+++ b/icu4c/source/common/uobject.cpp
@@ -58,32 +58,32 @@
* and replace with uprv_malloc/uprv_free.
*/
-void * U_EXPORT2 UMemory::operator new(size_t size) U_NO_THROW {
+void * U_EXPORT2 UMemory::operator new(size_t size) U_NOEXCEPT {
return uprv_malloc(size);
}
-void U_EXPORT2 UMemory::operator delete(void *p) U_NO_THROW {
+void U_EXPORT2 UMemory::operator delete(void *p) U_NOEXCEPT {
if(p!=NULL) {
uprv_free(p);
}
}
-void * U_EXPORT2 UMemory::operator new[](size_t size) U_NO_THROW {
+void * U_EXPORT2 UMemory::operator new[](size_t size) U_NOEXCEPT {
return uprv_malloc(size);
}
-void U_EXPORT2 UMemory::operator delete[](void *p) U_NO_THROW {
+void U_EXPORT2 UMemory::operator delete[](void *p) U_NOEXCEPT {
if(p!=NULL) {
uprv_free(p);
}
}
#if U_HAVE_DEBUG_LOCATION_NEW
-void * U_EXPORT2 UMemory::operator new(size_t size, const char* /*file*/, int /*line*/) U_NO_THROW {
+void * U_EXPORT2 UMemory::operator new(size_t size, const char* /*file*/, int /*line*/) U_NOEXCEPT {
return UMemory::operator new(size);
}
-void U_EXPORT2 UMemory::operator delete(void* p, const char* /*file*/, int /*line*/) U_NO_THROW {
+void U_EXPORT2 UMemory::operator delete(void* p, const char* /*file*/, int /*line*/) U_NOEXCEPT {
UMemory::operator delete(p);
}
#endif /* U_HAVE_DEBUG_LOCATION_NEW */
diff --git a/icu4c/source/common/uresimp.h b/icu4c/source/common/uresimp.h
index 71c5959..51db6c5 100644
--- a/icu4c/source/common/uresimp.h
+++ b/icu4c/source/common/uresimp.h
@@ -109,10 +109,10 @@
class U_COMMON_API StackUResourceBundle {
public:
// No heap allocation. Use only on the stack.
- static void* U_EXPORT2 operator new(size_t) U_NO_THROW = delete;
- static void* U_EXPORT2 operator new[](size_t) U_NO_THROW = delete;
+ static void* U_EXPORT2 operator new(size_t) U_NOEXCEPT = delete;
+ static void* U_EXPORT2 operator new[](size_t) U_NOEXCEPT = delete;
#if U_HAVE_PLACEMENT_NEW
- static void* U_EXPORT2 operator new(size_t, void*) U_NO_THROW = delete;
+ static void* U_EXPORT2 operator new(size_t, void*) U_NOEXCEPT = delete;
#endif
StackUResourceBundle();
diff --git a/icu4c/source/i18n/fphdlimp.h b/icu4c/source/i18n/fphdlimp.h
index d4a7685..0093783 100644
--- a/icu4c/source/i18n/fphdlimp.h
+++ b/icu4c/source/i18n/fphdlimp.h
@@ -73,10 +73,10 @@
// to be destroyed before status goes out of scope. Easiest thing is to
// allocate us on the stack in the same (or narrower) scope as status has.
// This attempts to encourage that by blocking heap allocation.
- static void* U_EXPORT2 operator new(size_t) U_NO_THROW = delete;
- static void* U_EXPORT2 operator new[](size_t) U_NO_THROW = delete;
+ static void* U_EXPORT2 operator new(size_t) U_NOEXCEPT = delete;
+ static void* U_EXPORT2 operator new[](size_t) U_NOEXCEPT = delete;
#if U_HAVE_PLACEMENT_NEW
- static void* U_EXPORT2 operator new(size_t, void*) U_NO_THROW = delete;
+ static void* U_EXPORT2 operator new(size_t, void*) U_NOEXCEPT = delete;
#endif
public: