can scopedallocatoradaptor be used with a custom allocator which is wrapped in a class so that it can be unwrapped for some types but not stl containers?

I am pretty sure the problem is that std::scoped_allocator_adaptor has an STLAdaptor allocator, not a CustomAllocator.

That’s correct as far as it goes. scoped_allocator_adaptor is going to pass down what it has, not some other type it doesn’t know about.

Additionally, scoped_allocator_adaptor will use uses_allocator to determine if the type uses the allocator. That trait defaults to looking at whether the type defines a member type allocator_type to which the allocator can be converted.

But then I can’t get it to work with an std::string either, but I think that has to do with the STLAdaptor having different types between the std::vector and the std::string (is this where rebind comes into play?

Correct. STLAdaptor doesn’t meet the allocator requirements.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top