Exploring some optional properties

C++ allocators provide some additional properties that are above and beyond is_always_equal. Specifically, the author of a C++ allocator can optionally define the following:

    • propagate_on_container_copy_assignment
    • propagate_on_container_move_assignment
    • propagate_on_container_swap

The optional properties tell a container how the allocator should be handled during a specific operation (that is, copy, move, and swap). Specifically, when a container is copied, moved, or swapped, the allocator isn't touched and, as we will show, this can result in inefficiencies. The propagate properties tell the container to propagate the operation to the allocator. For example, if propagate_on_container_copy_assignment ...

Get Hands-On System Programming with C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.