#cpp17
4 posts tagged #cpp17.
Copying a pmr::vector silently drops its allocator
A pmr::vector looks like a value type, but copy construction does not copy its allocator: select_on_container_copy_construction returns the default resource, so a copied container silently allocates from the global heap. The propagation traits make the allocator sticky. Episode 4 of the pmr series.
A pmr::vector on a stack buffer never calls new
The HFT and game-loop promise of pmr, made testable: override operator new to count heap allocations, then fill a pmr::vector from a monotonic_buffer_resource backed by a stack buffer with null_memory_resource upstream. Ten thousand pushes, zero heap calls. Episode 2 of the pmr series.
std::pmr is one abstract class with three functions
The whole std::pmr framework is one abstract class, std::pmr::memory_resource, with three functions to override: allocate, deallocate, is_equal. A dozen-line logging resource shows a pmr::vector's allocations, then a monotonic_buffer_resource placed in front of it collapses them to zero. Episode 1 of the pmr series.
Boost and Abseil start deleting their C++14 shims
Two release notes nine days apart point the same way. Boost 1.92 tells Heap and Lockfree users that C++14 support ends here, and Abseil's August LTS deprecates absl::void_t in favour of the standard one. Both are removing code that only ever existed because C++17 was not yet safe to assume.