September 2017
Beginner to intermediate
384 pages
9h 18m
English
The biggest difference between the standard polymorphic_allocator and our example WidgetAlloc is that polymorphic_allocator is default-constructible. Default-constructibility is arguably an attractive feature of an allocator; it means that we can write the second of these two lines instead of the first:
std::pmr::vector<int> v2({1, 2, 3}, std::pmr::new_delete_resource()); // Specifying a specific memory resource std::pmr::vector<int> v1 = {1, 2, 3}; // Using the default memory resource
On the other hand, when you look at that second line, you might wonder, "Where is the underlying array actually being allocated?" After all, the main point of specifying an allocator is that we want to know where our bytes ...
Read now
Unlock full access