]> granicus.if.org Git - icu/commitdiff
ICU-21174 Add adopt*() to MemoryPool and MaybeStackVector
authorHugo van der Merwe <17109322+hugovdm@users.noreply.github.com>
Fri, 19 Jun 2020 12:10:17 +0000 (14:10 +0200)
committerHugo van der Merwe <17109322+hugovdm@users.noreply.github.com>
Tue, 23 Jun 2020 14:21:24 +0000 (16:21 +0200)
Also add more const-correctness, including getConstAlias().

icu4c/source/common/cmemory.h

index dccbcee9c0e663f223a0b63322858ade75bbc47d..e628e344b214497363bb2f9872ce2ac54096f53b 100644 (file)
@@ -742,8 +742,8 @@ public:
      * @param status Is set to U_MEMORY_ALLOCATION_ERROR if allocation of the
      * needed pool capacity fails.
      */
-    template<typename... Args>
-    void adoptBack(T* ptr, UErrorCode& status) {
+    template <typename... Args>
+    void adopt(T *ptr, UErrorCode &status) {
         if (U_FAILURE(status)) {
             return;
         }
@@ -821,7 +821,7 @@ public:
      * needed pool capacity fails.
      */
     void adoptBack(T *ptr, UErrorCode &status) {
-        MemoryPool<T, stackCapacity>::adoptBack(ptr, status);
+        this->adopt(ptr, status);
     }
 
     int32_t length() const {