Skip to content

Commit

Permalink
[inplace_vector] WIP, allocator parameter
Browse files Browse the repository at this point in the history
This might be the direction that P0843 takes after R10.
It has some advantages, but boy it's a lot more complicated.
  • Loading branch information
Quuxplusone committed Dec 9, 2023
1 parent 0eea95d commit 3e15e06
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 59 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Boost also provides all four adaptors; see [`boost::container::flat_set`](https:
```
#include <sg14/inplace_vector.h>
template<class T, size_t N>
template<class T, size_t N, class A = allocator<T>>
class sg14::inplace_vector;
```

Expand All @@ -113,6 +113,13 @@ and will likely be in C++26. The `sg14` version is portable back to C++17.

Boost provides this container under the name [`boost::container::static_vector`](https://www.boost.org/doc/libs/1_83_0/doc/html/container/non_standard_containers.html#container.non_standard_containers.static_vector).

#### Why the allocator parameter?

Typical users of `inplace_vector` should simply pretend the allocator parameter isn't there.
`inplace_vector` will never call `A::allocate` nor `A::deallocate`. But it will still respect
`A::construct` (important to users of "scoped" allocators like `std::pmr`), and its iterators
will be `A::pointer` (possibly important to users of Boost.Interprocess).

#### Why not `std::erase{,_if}(inplace_vector, x)`?

We shouldn't inject our own overloads into `namespace std`.
Expand Down

0 comments on commit 3e15e06

Please sign in to comment.