On this page
std::ranges::views::as_rvalue, std::ranges::as_rvalue_view
Defined in header <ranges> |
||
|---|---|---|
|
(1) | (since C++23) |
|
(2) | (since C++23) |
| Call signature | ||
|
(since C++23) |
1) A range adaptor that represents a view of underlying
2) RangeAdaptorObject. Let view whose elements are rvalues.
e be a subexpression and let T be decltype((e)). Then the expression views::as_rvalue(e) is expression-equivalent to:
views::all(e), if it is a well-formed expression andstd::same_as<ranges::range_rvalue_reference_t<T>, ranges::range_reference_t<T>>istrue;as_rvalue_view{e}otherwise.
Data members
| Member object | Definition |
|---|---|
base_ (private) |
The underlying view of type V.(exposition-only member object*) |
Member functions
constructs an as_rvalue_view (public member function) |
|
returns the underlying view V (public member function) |
|
returns the beginning iterator of the as_rvalue_view (public member function) |
|
returns the end iterator of the as_rvalue_view (public member function) |
|
| returns the size of the view if it is bounded (public member function) |
|
Inherited from |
|
|
(C++20)
|
returns whether the derived view is empty. Provided if it satisfies sized_range or forward_range. (public member function of std::ranges::view_interface<D>) |
|
(C++23)
|
returns a constant iterator to the beginning of the range. (public member function of std::ranges::view_interface<D>) |
|
(C++23)
|
returns a sentinel for the constant iterator of the range. (public member function of std::ranges::view_interface<D>) |
|
(C++20)
|
returns whether the derived view is not empty. Provided if ranges::empty is applicable to it. (public member function of std::ranges::view_interface<D>) |
|
(C++20)
|
returns the first element in the derived view. Provided if it satisfies forward_range. (public member function of std::ranges::view_interface<D>) |
|
(C++20)
|
returns the last element in the derived view. Provided if it satisfies bidirectional_range and common_range. (public member function of std::ranges::view_interface<D>) |
|
(C++20)
|
returns the nth element in the derived view. Provided if it satisfies random_access_range. (public member function of std::ranges::view_interface<D>) |
std::ranges::as_rvalue_view::as_rvalue_view
|
(1) | (since C++23) |
|
(2) | (since C++23) |
1) Value-initializes
base_ via its default member initializer (= V()).
2) Initializes
base_ with std::move(base).
Parameters
| base | - | a view |
std::ranges::as_rvalue_view::base
|
(1) | (since C++23) |
|
(2) | (since C++23) |
Returns the underlying view.
1) Copy-constructs the result from the underlying view. Equivalent to
return base_;.
2) Move-constructs the result from the underlying view. Equivalent to
return std::move(base_);.
std::ranges::as_rvalue_view::begin
|
(1) | (since C++23) |
|
(2) | (since C++23) |
1,2) Returns
std::move_iterator(ranges::begin(base_)).
std::ranges::as_rvalue_view::end
|
(1) | (since C++23) |
|
(2) | (since C++23) |
1) Returns
std::move_iterator(ranges::end(base_)) if V models common_range, otherwise std::move_sentinel(ranges::end(base_)).
2) Returns
std::move_iterator(ranges::end(base_)) if const V models common_range, otherwise std::move_sentinel(ranges::end(base_)).
std::ranges::as_rvalue_view::size
|
(1) | (since C++23) |
|
(2) | (since C++23) |
Returns the size of the view if the view is bounded.
1,2) Equivalent to
return ranges::size(base_);
Deduction guides
|
(since C++23) |
Helper templates
|
(since C++23) |
This specialization of std::ranges::enable_borrowed_range makes as_rvalue_view satisfy borrowed_range when the underlying view satisfies it.
Notes
| Feature-test macro | Value | Std | Feature |
|---|---|---|---|
__cpp_lib_ranges_as_rvalue |
202207L | (C++23) | std::ranges::as_rvalue_view |
Example
See also
|
(C++11)
|
iterator adaptor which dereferences to an rvalue reference (class template) |
|
(C++20)
|
sentinel adaptor for use with std::move_iterator (class template) |
|
(C++23)
|
converts a view into a constant_range(class template) (range adaptor object) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/ranges/as_rvalue_view