diff options
Diffstat (limited to 'test/support/min_allocator.h')
-rw-r--r-- | test/support/min_allocator.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/support/min_allocator.h b/test/support/min_allocator.h index 8e0afab476342..d518e4a6d77cb 100644 --- a/test/support/min_allocator.h +++ b/test/support/min_allocator.h @@ -42,6 +42,44 @@ public: friend bool operator!=(bare_allocator x, bare_allocator y) {return !(x == y);} }; + +template <class T> +class no_default_allocator +{ +#if TEST_STD_VER >= 11 + no_default_allocator() = delete; +#else + no_default_allocator(); +#endif + struct construct_tag {}; + explicit no_default_allocator(construct_tag) {} + +public: + static no_default_allocator create() { + construct_tag tag; + return no_default_allocator(tag); + } + +public: + typedef T value_type; + + template <class U> + no_default_allocator(no_default_allocator<U>) TEST_NOEXCEPT {} + + T* allocate(std::size_t n) + { + return static_cast<T*>(::operator new(n*sizeof(T))); + } + + void deallocate(T* p, std::size_t) + { + return ::operator delete(static_cast<void*>(p)); + } + + friend bool operator==(no_default_allocator, no_default_allocator) {return true;} + friend bool operator!=(no_default_allocator x, no_default_allocator y) {return !(x == y);} +}; + struct malloc_allocator_base { static size_t alloc_count; static size_t dealloc_count; |