-
Notifications
You must be signed in to change notification settings - Fork 7
Description
I wanted to drop this in to replace std::vector, but unfortunately I am unable to.
With std::vector, I am able to use an empty/default constructed instance as a 'literal value' ie, the following static_assert can be evaluated at compile time:
constexpr auto foo = std::vector<uint8_t>{};
static_assert(foo.empty());Looking at the source, I see that the code specifically handles consteval contexts and (if I am reading correctly) always uses allocator. This explains the error about an empty constexpr small_vector<> containing heap allocations, and I imagine/guess that this is to avoid difficulty in switching between "heap" and "inline" storage in a consteval context.
Anyway, not sure if this is something that should even be supported, but I don't see a technical reason why small_vector couldn't be literal when contents fit inline, or at least when empty. And it would be one more way it is compatible with std::vector.