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, ...