A range adaptor that represents a view of underlying
view
whose elements are rvalues.
[edit] Data members Member DescriptionV
base_
(private) the underlying view
as_rvalue_view
V
as_rvalue_view
as_rvalue_view
approximately_sized_range
sized_range
or forward_range
std::ranges::view_interface<D>
) [edit] returns a constant iterator to the beginning of the range
std::ranges::view_interface<D>
) [edit] returns a sentinel for the constant iterator of the range
std::ranges::view_interface<D>
) [edit] returns whether the derived view is not empty, provided only if ranges::empty is applicable to it
std::ranges::view_interface<D>
) [edit] returns the first element in the derived view, provided if it satisfies forward_range
std::ranges::view_interface<D>
) [edit] returns the last element in the derived view, provided only if it satisfies bidirectional_range
and common_range
std::ranges::view_interface<D>
) [edit] returns the n
th element in the derived view, provided only if it satisfies random_access_range
std::ranges::view_interface<D>
) [edit] std::ranges::as_rvalue_view::as_rvalue_view (1) (since C++23)
constexpr explicit as_rvalue_view( V base );
(2) (since C++23) 1)Value-initializes
base_
via its default member initializer (
= V()).
2)Initializes
base_
with
std::move(base).
Parameters std::ranges::as_rvalue_view::base (1) (since C++23)constexpr V base() &&;
(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::sizeReturns the size of the view if the view is bounded. Equivalent to return ranges::size(base_
);.
constexpr auto reserve_hint()
requires ranges::approximately_sized_range<V>;
constexpr auto reserve_hint() const
requires ranges::approximately_sized_range<const V>;
Returns ranges::reserve_hint(base_
).
This specialization of ranges::enable_borrowed_range makes as_rvalue_view
satisfy borrowed_range
when the underlying view satisfies it.
#include <algorithm> #include <iostream> #include <ranges> #include <string> #include <vector> int main() { std::vector<std::string> words = {"Quick", "red", "\N{FOX FACE}", "jumped", "over", "a", "pterodactyl"}; std::vector<std::string> new_words; std::ranges::copy( words | std::views::as_rvalue, std::back_inserter(new_words)); // move string from words into new_words auto quoted = std::views::transform([](auto&& s) { return "â" + s + "â"; }); std::cout << "Old words: "; for (auto&& word : words | std::views::as_rvalue | quoted) std::cout << word << ' '; std::cout << "\nNew words: "; for (auto&& word : new_words | std::views::as_rvalue | quoted) std::cout << word << ' '; }
Possible output:
Old words: ââ ââ ââ ââ ââ ââ ââ New words: âQuickâ âredâ âð¦â âjumpedâ âoverâ âaâ âpterodactylâ[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior LWG 4083 C++23views::as_rvalue
used to accept non-input ranges made rejected [edit] See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4