c++stdc++20std-span

Is std::span a view?


Is std::span a view?

My speculation stems from the fact that it does not "own".

I have read that it is a reference to ranges here and that it "just wraps" I have not seen anywhere been stated explicitly that it is a view.


Solution

  • Generally span is a reference-like class type.

    As for "view": is this related to what you're asking? (source)

    template<class T, std::size_t Extent> inline constexpr bool
    ranges::enable_view<std::span<T, Extent>> = true; 
    

    This specialization of ranges::enable_view makes span satisfy view.