#pragma once // std #include #include #include namespace DOS { template struct wrapped_array { wrapped_array(T* first, T* last) : begin_ {first}, end_ {last} {} wrapped_array(T* first, std::ptrdiff_t size) : wrapped_array {first, first + size} {} T* begin() const noexcept { return begin_; } T* end() const noexcept { return end_; } T* begin_; T* end_; }; template wrapped_array wrap_array(T* first, std::ptrdiff_t size) noexcept { return {first, size}; } template std::vector toVector(G* first, std::ptrdiff_t size) noexcept { const wrapped_array array = wrap_array(first, size); std::vector result; for (auto it = array.begin(); it != array.end(); ++it) result.emplace_back(T(*it)); return result; } template ::type> std::vector toVector(T* first, std::ptrdiff_t size, K f) noexcept { wrapped_array array = wrap_array(first, size); std::vector result; for (auto it = array.begin(); it != array.end(); ++it) result.emplace_back(R(f(*it))); return result; } }