1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-29 10:02:57 +03:00

Support building ArrayView from contigous iterators

This commit is contained in:
Maxime Coste 2023-11-10 16:32:27 +11:00
parent feeacd8de9
commit fbbced5ed0

View File

@ -27,6 +27,11 @@ public:
constexpr ArrayView(T* begin, T* end)
: m_pointer(begin), m_size(end - begin) {}
template<typename It>
requires std::contiguous_iterator<It> and std::is_same_v<std::iter_value_t<It>, T>
constexpr ArrayView(It begin, It end)
: m_pointer(&*begin), m_size(end - begin) {}
template<size_t N>
constexpr ArrayView(T(&array)[N]) : m_pointer(array), m_size(N) {}
@ -68,6 +73,10 @@ private:
size_t m_size;
};
template<typename It>
requires std::contiguous_iterator<It>
ArrayView(It begin, It end) -> ArrayView<std::iter_value_t<It>>;
template<typename T>
using ConstArrayView = ArrayView<const T>;