Skip to content

Commit

Permalink
Tidy up and add destruction helper
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcoe committed Jun 29, 2024
1 parent 2d338df commit c12188e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions TALK.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ No change to remaining member function interfaces.
using allocator_traits = std::allocator_traits<Allocator>;
using pointer = typename allocator_traits::pointer;
// ...
template <typename... Us>
static pointer construct_from(A alloc, Us&&... us) {
pointer mem = allocator_traits::allocate(alloc, 1);
Expand All @@ -503,6 +505,22 @@ No change to remaining member function interfaces.

---

## `dyn_optional` Allocator-destruction helper

```cpp
using allocator_traits = std::allocator_traits<Allocator>;
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<T,A>` Constructors with allocators
Use the allocator-construction helper in constructors
Expand Down Expand Up @@ -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.

0 comments on commit c12188e

Please sign in to comment.