diff --git a/test/cfoa/constructor_tests.cpp b/test/cfoa/constructor_tests.cpp index 39fbc76a..1256fa7e 100644 --- a/test/cfoa/constructor_tests.cpp +++ b/test/cfoa/constructor_tests.cpp @@ -44,34 +44,6 @@ template struct soccc_allocator bool operator!=(soccc_allocator const& rhs) const { return x_ != rhs.x_; } }; -template struct stateful_allocator -{ - int x_ = -1; - - using value_type = T; - - stateful_allocator() = default; - stateful_allocator(stateful_allocator const&) = default; - stateful_allocator(stateful_allocator&&) = default; - - stateful_allocator(int const x) : x_{x} {} - - template - stateful_allocator(stateful_allocator const& rhs) : x_{rhs.x_} - { - } - - T* allocate(std::size_t n) - { - return static_cast(::operator new(n * sizeof(T))); - } - - void deallocate(T* p, std::size_t) { ::operator delete(p); } - - bool operator==(stateful_allocator const& rhs) const { return x_ == rhs.x_; } - bool operator!=(stateful_allocator const& rhs) const { return x_ != rhs.x_; } -}; - using hasher = stateful_hash; using key_equal = stateful_key_equal; using allocator_type = stateful_allocator >; diff --git a/test/cfoa/helpers.hpp b/test/cfoa/helpers.hpp index e630cd9c..8323393f 100644 --- a/test/cfoa/helpers.hpp +++ b/test/cfoa/helpers.hpp @@ -103,6 +103,34 @@ struct stateful_key_equal } }; +template struct stateful_allocator +{ + int x_ = -1; + + using value_type = T; + + stateful_allocator() = default; + stateful_allocator(stateful_allocator const&) = default; + stateful_allocator(stateful_allocator&&) = default; + + stateful_allocator(int const x) : x_{x} {} + + template + stateful_allocator(stateful_allocator const& rhs) : x_{rhs.x_} + { + } + + T* allocate(std::size_t n) + { + return static_cast(::operator new(n * sizeof(T))); + } + + void deallocate(T* p, std::size_t) { ::operator delete(p); } + + bool operator==(stateful_allocator const& rhs) const { return x_ == rhs.x_; } + bool operator!=(stateful_allocator const& rhs) const { return x_ != rhs.x_; } +}; + struct raii { static std::atomic default_constructor;