//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef ALLOCATORS_H #define ALLOCATORS_H #include #include #include "test_macros.h" #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template class A1 { int id_; public: explicit A1(int id = 0) TEST_NOEXCEPT : id_(id) {} typedef T value_type; int id() const {return id_;} static bool copy_called; static bool move_called; static bool allocate_called; static std::pair deallocate_called; A1(const A1& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;} A1(A1&& a) TEST_NOEXCEPT : id_(a.id()) {move_called = true;} template A1(const A1& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;} template A1(A1&& a) TEST_NOEXCEPT : id_(a.id()) {move_called = true;} T* allocate(std::size_t n) { allocate_called = true; return (T*)n; } void deallocate(T* p, std::size_t n) { deallocate_called = std::pair(p, n); } std::size_t max_size() const {return id_;} }; template bool A1::copy_called = false; template bool A1::move_called = false; template bool A1::allocate_called = false; template std::pair A1::deallocate_called; template inline bool operator==(const A1& x, const A1& y) { return x.id() == y.id(); } template inline bool operator!=(const A1& x, const A1& y) { return !(x == y); } template class A2 { int id_; public: explicit A2(int id = 0) TEST_NOEXCEPT : id_(id) {} typedef T value_type; typedef unsigned size_type; typedef int difference_type; typedef std::true_type propagate_on_container_move_assignment; int id() const {return id_;} static bool copy_called; static bool move_called; static bool allocate_called; A2(const A2& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;} A2(A2&& a) TEST_NOEXCEPT : id_(a.id()) {move_called = true;} T* allocate(std::size_t n, const void* hint) { allocate_called = true; return (T*)hint; } }; template bool A2::copy_called = false; template bool A2::move_called = false; template bool A2::allocate_called = false; template inline bool operator==(const A2& x, const A2& y) { return x.id() == y.id(); } template inline bool operator!=(const A2& x, const A2& y) { return !(x == y); } template class A3 { int id_; public: explicit A3(int id = 0) TEST_NOEXCEPT : id_(id) {} typedef T value_type; typedef std::true_type propagate_on_container_copy_assignment; typedef std::true_type propagate_on_container_swap; int id() const {return id_;} static bool copy_called; static bool move_called; static bool constructed; static bool destroy_called; A3(const A3& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;} A3(A3&& a) TEST_NOEXCEPT: id_(a.id()) {move_called = true;} template void construct(U* p, Args&& ...args) { ::new (p) U(std::forward(args)...); constructed = true; } template void destroy(U* p) { p->~U(); destroy_called = true; } A3 select_on_container_copy_construction() const {return A3(-1);} }; template bool A3::copy_called = false; template bool A3::move_called = false; template bool A3::constructed = false; template bool A3::destroy_called = false; template inline bool operator==(const A3& x, const A3& y) { return x.id() == y.id(); } template inline bool operator!=(const A3& x, const A3& y) { return !(x == y); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // ALLOCATORS_H