Back to 2014-proposals
Title: Rehabilitating Allocators in C++11/14
Proposer: Alisdair Meredith
Type: Presentation
Duration: 90 mins
Description:
The original C++ standard allowed containers to be parameterized on allocators, without nailing down what that would mean in practice. The result was a dark corner of the standard that is widely ignored.
For C++11, there was a desire to more more ambitious things with allocators, so we started by building more solid foundations. The resulting feature in C++11 makes it much simpler to write custom allocators and plug them into standard library facilities. It also spells out many of the ideas required to produce a coherent allocator model, so that the library can use your allocators consistently.
While this is essentially transparent to the end user, who can now simply plug in the (well specified) allocator of their choice, it does have a bearing on how containers and other allocator-aware components should be written for a C++11 world; namely, library code should never invoke an allocator directly, but request its services through the new 'allocator_traits' facility.
The design and implementation of 'allocator_traits' itself presents an interesting case study in the compile-time reflection features of modern C++.
This session will present motivation for exploring custom allocators; the design of the 'allocator_traits' facility and how it can support many different allocator models; how modern library code should be written using the 'allocator_traits'; and explore some of the more interesting template techniques that this new facility requires from standard library vendors - here may (or may not) be lessons on general purpose library design to be drawn from this specification!