From fbbced5ed06236f36648b02f40845a5e17763857 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 10 Nov 2023 16:32:27 +1100 Subject: [PATCH] Support building ArrayView from contigous iterators --- src/array_view.hh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/array_view.hh b/src/array_view.hh index 2d971089..98f3c811 100644 --- a/src/array_view.hh +++ b/src/array_view.hh @@ -27,6 +27,11 @@ public: constexpr ArrayView(T* begin, T* end) : m_pointer(begin), m_size(end - begin) {} + template + requires std::contiguous_iterator and std::is_same_v, T> + constexpr ArrayView(It begin, It end) + : m_pointer(&*begin), m_size(end - begin) {} + template constexpr ArrayView(T(&array)[N]) : m_pointer(array), m_size(N) {} @@ -68,6 +73,10 @@ private: size_t m_size; }; +template + requires std::contiguous_iterator +ArrayView(It begin, It end) -> ArrayView>; + template using ConstArrayView = ArrayView;