Propagating different allocators

In my introduction of scoped_allocator_adaptor<A>, I left out one more complication. The template parameter list isn't limited to just one allocator type argument! You can actually create a scoped-allocator type with multiple allocator type arguments, like this:

    using InnerAlloc = WidgetAlloc<int>;    using InnerVector = std::vector<int, InnerAlloc>;    using MiddleAlloc = std::scoped_allocator_adaptor<      WidgetAlloc<InnerVector>,      WidgetAlloc<int>    >;    using MiddleVector = std::vector<InnerVector, MiddleAlloc>;    using OuterAlloc = std::scoped_allocator_adaptor<      WidgetAlloc<MiddleVector>,      WidgetAlloc<InnerVector>,      WidgetAlloc<int>    >;    using OuterVector = std::vector<MiddleVector, OuterAlloc>;

Having set up these typedefs, ...

Get Mastering the C++17 STL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.