template <typename T, size_t N, typename Allocator>
class small_vector {
union {
static_vector<T, N> inline;
std::vector<T, Allocator> heap;
} storage;
};
.... 🤔
template <typename T, size_t N, typename Allocator>
class small_vector {
union {
static_vector<T, N> inline;
std::vector<T, Allocator> heap;
} storage;
};
.... 🤔
Upside: easiest implementation of my life.
Downside: I have to store the discriminant outside the storage, so I can't know which is which without taking extra space for that.
@rjmccall @dgregor79 @thephd @steve I'm a fan of non-stack uses, where the goal is long-term memory size improvement.
I might be persuaded that there are only two right answers: N=1 and N=<whatever fits in pointer-size storage>, with in-line discriminators.