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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.