4 ms·
If `push_back()` & friends took an (optional) extra allocator parameter, it'd be pretty ideal. It'd be nicer if the implementations were forced to be single-wor
by thechao 4y ago
If `push_back()` & friends took an (optional) extra allocator parameter, it'd be pretty ideal. It'd be nicer if the implementations were forced to be single-word containers like Stepanov wanted...
- messe 4y agostd::vector can take an allocator as a template parameter though? For a list, sure I can see that having a separate allocator per element could work, but for a vector, surely you'd want the same allocator for the entire range? EDIT: assuming we're talking about C++, if not please don't hesitate to corrrect me.
- thechao 4y agoStateful allocators require a word be dedicated to the allocator in the header. In my use cases, I always have access to the allocator, but I need to create a lot of containers — most staying empty, to boot! Paying the extra overhead is morally objectionable.
- messe 4y agoC++ might have the advantage here then: it's a template parameter, in other words, the allocator is decided at compile-time, meaning that no additional storage space would be needed if you know in advance which allocator you intend on using.