Optimizing: Allow storing value objects in containers.
Change-Id: Ic9c6b62e36706e571fd71c18d24d8e76ae2d5c7b
diff --git a/runtime/base/macros.h b/runtime/base/macros.h
index 1d5dee2..dc692d2 100644
--- a/runtime/base/macros.h
+++ b/runtime/base/macros.h
@@ -68,9 +68,12 @@
DISALLOW_COPY_AND_ASSIGN(TypeName)
// A macro to disallow new and delete operators for a class. It goes in the private: declarations.
+// NOTE: Providing placement new (and matching delete) for constructing container elements.
#define DISALLOW_ALLOCATION() \
public: \
NO_RETURN ALWAYS_INLINE void operator delete(void*, size_t) { UNREACHABLE(); } \
+ ALWAYS_INLINE void* operator new(size_t, void* ptr) noexcept { return ptr; } \
+ ALWAYS_INLINE void operator delete(void*, void*) noexcept { } \
private: \
void* operator new(size_t) = delete