Make util::span constructible from any container with data() and size() methods

This commit is contained in:
Nikita Lisitsa 2021-08-22 13:11:10 +03:00
parent 8985436906
commit a0e81aaf32

View file

@ -1,7 +1,6 @@
#pragma once #pragma once
#include <iterator> #include <iterator>
#include <array>
namespace psemek::util namespace psemek::util
{ {
@ -42,10 +41,10 @@ namespace psemek::util
, p_end{a + N} , p_end{a + N}
{} {}
template <std::size_t N> template <typename Container>
span(std::array<T, N> & a) span(Container & a)
: p_begin{a.data()} : p_begin{a.data()}
, p_end{a.data() + N} , p_end{a.data() + a.size()}
{} {}
span & operator =(span const &) = default; span & operator =(span const &) = default;