diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2016-08-17 05:58:40 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2016-08-17 05:58:40 +0000 |
commit | 2a10c960fa33b7048b48107823f5879cf301dece (patch) | |
tree | 055ff7b53c98af2ffcc7abc42a03e4aa1b42f502 /libcxx/test/support | |
parent | 14f383e9c4b776d415cbc66902d8492dbcc0c0e1 (diff) | |
download | bcm5719-llvm-2a10c960fa33b7048b48107823f5879cf301dece.tar.gz bcm5719-llvm-2a10c960fa33b7048b48107823f5879cf301dece.zip |
Support allocators with explicit conversion constructors. Fixes bug #29000
llvm-svn: 278904
Diffstat (limited to 'libcxx/test/support')
-rw-r--r-- | libcxx/test/support/min_allocator.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libcxx/test/support/min_allocator.h b/libcxx/test/support/min_allocator.h index 701159e0481..8e0afab4763 100644 --- a/libcxx/test/support/min_allocator.h +++ b/libcxx/test/support/min_allocator.h @@ -340,6 +340,31 @@ public: friend bool operator!=(min_allocator x, min_allocator y) {return !(x == y);} }; +template <class T> +class explicit_allocator +{ +public: + typedef T value_type; + + explicit_allocator() TEST_NOEXCEPT {} + + template <class U> + explicit explicit_allocator(explicit_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==(explicit_allocator, explicit_allocator) {return true;} + friend bool operator!=(explicit_allocator x, explicit_allocator y) {return !(x == y);} +}; + #endif // TEST_STD_VER >= 11 #endif // MIN_ALLOCATOR_H |