diff --git a/TALK.md b/TALK.md index 5eab60e..2703d51 100644 --- a/TALK.md +++ b/TALK.md @@ -487,6 +487,8 @@ No change to remaining member function interfaces. using allocator_traits = std::allocator_traits; using pointer = typename allocator_traits::pointer; + // ... + template static pointer construct_from(A alloc, Us&&... us) { pointer mem = allocator_traits::allocate(alloc, 1); @@ -503,6 +505,22 @@ No change to remaining member function interfaces. --- +## `dyn_optional` Allocator-destruction helper + +```cpp + using allocator_traits = std::allocator_traits; + using pointer = typename allocator_traits::pointer; + + // ... + + constexpr static void destroy_with(A alloc, pointer p) { + allocator_traits::destroy(alloc, std::to_address(p)); + allocator_traits::deallocate(alloc, p, 1); + } +``` + +--- + ## `dyn_optional` Constructors with allocators Use the allocator-construction helper in constructors @@ -564,14 +582,16 @@ Use the allocator-construction helper in allocator-extended copy and move constr Thanks to: -* Nina Ranns for fielding our regular questions on allocators. +* My coauthor Ant Peacock. -* Bob Steagall for his excellent cppcon 2017 talk on allocators. +* Nina Ranns for fielding our regular questions on allocators. * Joshua Berne for pair-debugging our early implementation of `polymorphic`. * Neelofer Banglawala for her help with the slides. +* Bob Steagall for his excellent cppcon 2017 talk on allocators. + * Assorted members of the C++ community for their ongoing work on allocators. We've been the grateful recipients of a great deal of wisdom. Mistakes are our own.