@@ -290,6 +290,13 @@ inline T *LocalMemory<T>::allocateInsteadAndCopy(int32_t newCapacity, int32_t le
290
290
template <typename T, int32_t stackCapacity>
291
291
class MaybeStackArray {
292
292
public:
293
+ // No heap allocation. Use only on the stack.
294
+ static void * U_EXPORT2 operator new (size_t ) U_NO_THROW = delete ;
295
+ static void * U_EXPORT2 operator new [](size_t ) U_NO_THROW = delete ;
296
+ #if U_HAVE_PLACEMENT_NEW
297
+ static void * U_EXPORT2 operator new (size_t , void *) U_NO_THROW = delete ;
298
+ #endif
299
+
293
300
/* *
294
301
* Default constructor initializes with internal T[stackCapacity] buffer.
295
302
*/
@@ -402,20 +409,6 @@ class MaybeStackArray {
402
409
/* No ownership transfer: No copy constructor, no assignment operator. */
403
410
MaybeStackArray (const MaybeStackArray & /* other*/ ) {}
404
411
void operator =(const MaybeStackArray & /* other*/ ) {}
405
-
406
- // No heap allocation. Use only on the stack.
407
- // (Declaring these functions private triggers a cascade of problems:
408
- // MSVC insists on exporting an instantiation of MaybeStackArray, which
409
- // requires that all functions be defined.
410
- // An empty implementation of new() is rejected, it must return a value.
411
- // Returning NULL is rejected by gcc for operator new.
412
- // The expedient thing is just not to override operator new.
413
- // While relatively pointless, heap allocated instances will function.
414
- // static void * U_EXPORT2 operator new(size_t size);
415
- // static void * U_EXPORT2 operator new[](size_t size);
416
- #if U_HAVE_PLACEMENT_NEW
417
- // static void * U_EXPORT2 operator new(size_t, void *ptr);
418
- #endif
419
412
};
420
413
421
414
template <typename T, int32_t stackCapacity>
@@ -512,6 +505,13 @@ inline T *MaybeStackArray<T, stackCapacity>::orphanOrClone(int32_t length, int32
512
505
template <typename H, typename T, int32_t stackCapacity>
513
506
class MaybeStackHeaderAndArray {
514
507
public:
508
+ // No heap allocation. Use only on the stack.
509
+ static void * U_EXPORT2 operator new (size_t ) U_NO_THROW = delete ;
510
+ static void * U_EXPORT2 operator new [](size_t ) U_NO_THROW = delete ;
511
+ #if U_HAVE_PLACEMENT_NEW
512
+ static void * U_EXPORT2 operator new (size_t , void *) U_NO_THROW = delete ;
513
+ #endif
514
+
515
515
/* *
516
516
* Default constructor initializes with internal H+T[stackCapacity] buffer.
517
517
*/
@@ -608,15 +608,6 @@ class MaybeStackHeaderAndArray {
608
608
/* No ownership transfer: No copy constructor, no assignment operator. */
609
609
MaybeStackHeaderAndArray (const MaybeStackHeaderAndArray & /* other*/ ) {}
610
610
void operator =(const MaybeStackHeaderAndArray & /* other*/ ) {}
611
-
612
- // No heap allocation. Use only on the stack.
613
- // (Declaring these functions private triggers a cascade of problems;
614
- // see the MaybeStackArray class for details.)
615
- // static void * U_EXPORT2 operator new(size_t size);
616
- // static void * U_EXPORT2 operator new[](size_t size);
617
- #if U_HAVE_PLACEMENT_NEW
618
- // static void * U_EXPORT2 operator new(size_t, void *ptr);
619
- #endif
620
611
};
621
612
622
613
template <typename H, typename T, int32_t stackCapacity>
0 commit comments