inline constexpr /*unspecified*/ transform = /*unspecified*/;
Call signature
(since C++20)template< class F >
constexpr /*range adaptor closure*/ transform( F&& fun );
A range adaptor that represents
view
of an underlying sequence after applying a transformation function to each element.
transform_view
models the concepts random_access_range
, bidirectional_range
, forward_range
, input_range
, common_range
, and sized_range
when the underlying view V
models respective concepts.
V
base_
(private) the underlying view
copyable-box
<F>
(until C++23)movable-box
<F>
(since C++23) fun_
(private) the underlying function object
transform_view
sized_range
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] [edit] Deduction guides [edit] Nested classes the iterator type
#include <algorithm> #include <cstdio> #include <iterator> #include <ranges> #include <string> char rot13a(const char x, const char a) { return a + (x - a + 13) % 26; } char rot13(const char x) { if ('Z' >= x and x >= 'A') return rot13a(x, 'A'); if ('z' >= x and x >= 'a') return rot13a(x, 'a'); return x; } int main() { auto show = [](const unsigned char x) { std::putchar(x); }; std::string in{"cppreference.com\n"}; std::ranges::for_each(in, show); std::ranges::for_each(in | std::views::transform(rot13), show); std::string out; std::ranges::copy(std::views::transform(in, rot13), std::back_inserter(out)); std::ranges::for_each(out, show); std::ranges::for_each(out | std::views::transform(rot13), show); }
Output:
cppreference.com pccersrerapr.pbz pccersrerapr.pbz cppreference.com[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