#include
#include
#include
#include
// g++ allocator_traits_test.cpp -std=c++11 -fPIC -Ofast -D_GLIBCXX_USE_CXX11_ABI=0 -o allocator_traits_test
template
struct custom_allocator {
typedef T value_type;
custom_allocator() noexcept {}
template custom_allocator (const custom_allocator&) noexcept {}
T* allocate (std::size_t n) { return static_cast(::operator new(n*sizeof(T))); }
void deallocate (T* p, std::size_t n) { ::operator delete(p); }
};
typedef std::allocator_traits>::rebind_alloc other_allcator;
template
constexpr bool operator== (const custom_allocator&, const custom_allocator&) noexcept
{return true;}
template
constexpr bool operator!= (const custom_allocator&, const custom_allocator&) noexcept
{return false;}
int main () {
std::vector foo = {10,20,30};
for (auto x: foo) std::cout << x << " ";
std::cout << 'n';
return 0;
}