fix: forgot to include a file
This commit is contained in:
parent
855ac4d654
commit
6288a43da7
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef TO_VECTOR_H
|
||||
#define TO_VECTOR_H
|
||||
|
||||
#include <ranges>
|
||||
#include <vector>
|
||||
|
||||
template <std::ranges::range R>
|
||||
auto to_vector(R&& r) {
|
||||
std::vector<std::ranges::range_value_t<R>> v;
|
||||
|
||||
// if we can get a size, reserve that much
|
||||
if constexpr (requires { std::ranges::size(r); }) {
|
||||
v.reserve(std::ranges::size(r));
|
||||
}
|
||||
|
||||
// push all the elements
|
||||
for (auto&& e : r) {
|
||||
v.push_back(static_cast<decltype(e)&&>(e));
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue