Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC++custom allocatorsSingle-choice MCQ

What is wrong with this minimal allocator intended for use with std::vector?

template <class T> struct MyAlloc { using value_type = T; MyAlloc() = default; T* allocate(std::size_t n) { return static_cast<T*>(::operator new(n * sizeof(T))); } void deallocate(T* p, std::size_t) { ::operator delete(p); } bool operator==(const MyAlloc&) const { return true; } bool operator!=(const MyAlloc&) const { return false; } };