smallvector.h: bake `reserve()` into the non-boost `SmallVector` implementation (#4385)

This commit is contained in:
Oliver Stöneberg 2022-08-20 20:44:26 +02:00 committed by GitHub
parent 5cc8ef7e87
commit 2afd5f80e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -42,7 +42,16 @@ struct TaggedAllocator : std::allocator<T>
}; };
template<typename T, std::size_t N = DefaultSmallVectorSize> template<typename T, std::size_t N = DefaultSmallVectorSize>
using SmallVector = std::vector<T, TaggedAllocator<T, N>>; class SmallVector : public std::vector<T, TaggedAllocator<T, N>>
{
public:
template<class ... Ts>
SmallVector(Ts&&... ts)
: std::vector<T, TaggedAllocator<T, N>>(std::forward<Ts>(ts)...)
{
this->reserve(N);
}
};
#endif #endif
#endif #endif