It's *oh so very close*, but not quite. The problem comes into the dirty details in the nesting. See https://isocpp.org/wiki/faq/cpp11-library#scoped-allocator1.) To pass the allocator down to containers contained, you have to drop std::String and use just basic_string. Other types also degenerate when using allocators like this.2.) I could very well be using it wrong, or not understanding it correctly. There very well *could* be a way to do this currently in the STL. It's non-obvious from digging through the types and containers currently, but I'm going over it with a fine toothed comb.
The person to ask is Alisdair Meredith. He has a thorough understanding of this topic. I could not find online information on this last year, but I got everything I needed from his talks at cppcon, namely:
Part I : https://www.youtube.com/watch?v=YkiYOP3d64E
Part II : https://www.youtube.com/watch?v=Q5kyiFevMJQ
He goes into a lot of detail, but I guess that what you guys are looking for.
Le lundi 22 septembre 2014 08:35:48 UTC-4, Ryan Ruzich a écrit :Got a reply back from STL. I'll paraphrase, since I didn't ask for his permission to repost, but he joked that even he doesn't understand scoped_allocator. I think people are still churning the allocator model, for good, bad, or ugly. It's probably too much to bite off for a first pass. I did come up with a hacky pattern for a unique ptr to control the lifetime of an object created on an aligned buffer with placement new.
On Tuesday, September 16, 2014 11:26:31 PM UTC-4, Sean Middleditch wrote:On Tuesday, September 16, 2014 12:22:52 PM UTC-7, Ryan Ruzich wrote:It's *oh so very close*, but not quite. The problem comes into the dirty details in the nesting. See https://isocpp.org/wiki/faq/cpp11-library#scoped-allocator1.) To pass the allocator down to containers contained, you have to drop std::String and use just basic_string. Other types also degenerate when using allocators like this.
2.) I could very well be using it wrong, or not understanding it correctly. There very well *could* be a way to do this currently in the STL. It's non-obvious from digging through the types and containers currently, but I'm going over it with a fine toothed comb.
The person to ask is Alisdair Meredith. He has a thorough understanding of this topic. I could not find online information on this last year, but I got everything I needed from his talks at cppcon, namely:
Part I : https://www.youtube.com/watch?v=YkiYOP3d64E
Part II : https://www.youtube.com/watch?v=Q5kyiFevMJQ
He goes into a lot of detail, but I guess that what you guys are looking for.