Category : stdvector

Is there a way to move already initialized data into a std::vector? Here’s my own super-simple vec class: template<typename T> class vec final { std::unique_ptr<T[]> pValues; size_t size = 0; public: std::span<T> span() const { return std::span<int>(pValues.get(), size); } vec(T* p, size_t sz) : size(sz) { pValues.reset(p); } }; As you can see, it will ..

Read more