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

A custom allocator is rebound by a container via `allocator_traits`. For `std::list<int, MyAlloc<int>>`, which rebind does the container actually use for its nodes, and why is the original `MyAlloc<int>` typically not used to allocate directly?

template <typename T> struct MyAlloc { using value_type = T; T* allocate(std::size_t n); void deallocate(T*, std::size_t); template <typename U> struct rebind { using other = MyAlloc<U>; }; };