]> granicus.if.org Git - icu/commitdiff
ICU-20265 Use noexcept instead of throw() in C++ >= 11.
authorRomain Geissler <romain.geissler@amadeus.com>
Fri, 9 Nov 2018 13:02:56 +0000 (13:02 +0000)
committerShane F. Carr <shane@unicode.org>
Fri, 22 Feb 2019 19:29:20 +0000 (13:29 -0600)
- Adds note directing users of U_NO_THROW to U_NOEXCEPT.

icu4c/source/common/cmemory.h
icu4c/source/common/unicode/uobject.h
icu4c/source/common/uobject.cpp
icu4c/source/common/uresimp.h
icu4c/source/i18n/fphdlimp.h

index 5c48547a5e2721d8ea19861b9fd042f2561e2fda..f121bcb8f11a9f8aab8c4d5979401bbe421205cc 100644 (file)
@@ -281,10 +281,10 @@ template<typename T, int32_t stackCapacity>
 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 @@ template<typename H, typename T, int32_t stackCapacity>
 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
 
     /**
index c42c720cc71041d5bf2c03f3797527c5546eae80..c2663ebff48bb82a02643e5793b3511ccf779add 100644 (file)
@@ -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 @@ public:
      * 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 @@ public:
      * 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 @@ public:
      * 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 @@ public:
       * @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 @@ public:
       * @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 */
 
index 1133dd9b67aaa6586f447eac1c43fcddeb45fb2f..e222b2ce9b90963013f4a9c799d09656f8792077 100644 (file)
@@ -58,32 +58,32 @@ U_NAMESPACE_BEGIN
  * 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 */
index 71c5959ad83744c1d1db282fa72cf90ce67e7320..51db6c52634848ac2edf541eadb889d59d45d79c 100644 (file)
@@ -109,10 +109,10 @@ U_NAMESPACE_BEGIN
 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();
index d4a76859025b88e9d8be19e0139449fbceb8b5fa..00937830fe7b801463c81bfa31ab6dc3d2d7d4c8 100644 (file)
@@ -73,10 +73,10 @@ class FieldPositionIteratorHandler : public FieldPositionHandler {
   // 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: