[range.as.const.overview] (original) (raw)

25 Ranges library [ranges]

25.7 Range adaptors [range.adaptors]

25.7.22 As const view [range.as.const]

25.7.22.1 Overview [range.as.const.overview]

as_const_view presents a view of an underlying sequence as constant.

That is, the elements of an as_const_view cannot be modified.

Let E be an expression, let T be decltype((E)), and let U be remove_cvref_t<T>.

The expression views​::​as_const(E) is expression-equivalent to:

[Example 1: template<constant_range R> void cant_touch_this(R&&); vector<char> hammer = {'m', 'c'}; span<char> beat = hammer; cant_touch_this(views::as_const(beat)); — _end example_]