26 Ranges library [ranges]

26.7 Range adaptors [range.adaptors]

26.7.22 As const view [range.as.const]

26.7.22.2 Class template as_const_view [range.as.const.view]

namespace std::ranges { template<view V> requires input_range<V> class as_const_view : public view_interface<as_const_view<V>> { V base_ = V(); // exposition only public: as_const_view() requires default_initializable<V> = default; constexpr explicit as_const_view(V base); constexpr V base() const & requires copy_constructible<V> { return base_; } constexpr V base() && { return std::move(base_); } constexpr auto begin() requires (!simple-view<V>) { return ranges::cbegin(base_); } constexpr auto begin() const requires range<const V> { return ranges::cbegin(base_); } constexpr auto end() requires (!simple-view<V>) { return ranges::cend(base_); } constexpr auto end() const requires range<const V> { return ranges::cend(base_); } constexpr auto size() requires sized_range<V> { return ranges::size(base_); } constexpr auto size() const requires sized_range<const V> { return ranges::size(base_); } }; template<class R> as_const_view(R&&) -> as_const_view<views::all_t<R>>; }
constexpr explicit as_const_view(V base);
Effects: Initializes base_ with std​::​move(base).