Mapping-related operations
Mapping values to other values.
| Name | Description |
|---|---|
| map_to | Map inputs to a new type. |
| map(const F &f) | Value generated from f(input). |
| map_nth(size_t nth) | Produce the nth value of input using operator[]. |
| Class | Description |
|---|---|
| piped::adl_map_to | This is used to customize type conversion. |
<T> map_to
<piped/map.hpp>
template<typename T>
constexpr detail::map_to_<T> piped::map_to
Description
Map inputs to a new type.
By default, this is a static_cast<To>. See adl_map_to for customizing this.
Example:
auto v = "a,b,c" | split(",") | map_to<std::string> | collect<std::vector>
// Produces a vector<string>, creating new strings,
// rather than a vector<string_view>
<F> map(const F &f)
<piped/map.hpp>
template<typename F>
detail::map_<F> piped::map(const F &f)
Description
Value generated from f(input).
Example:
auto v = from_to(1,4)
| map([](auto v) { return v + 1; })
| collect<std::vector>;
/// Produces [2,3,4] as a vector<int>
| Parameter | ||
|---|---|---|
f | const F & |
map_nth(size_t nth)
<piped/map.hpp>
detail::map_nth_ piped::map_nth(size_t nth)
Description
Produce the nth value of input using operator[].
Example:
auto s = "X:Y:Z:"s;
auto v = s
| each_match(".:") // match_data
| map_nth(0) // nth submatch
| map_to<std::string_view>
| collect<std::vector>;
// Produce ["X:", "Y:", "Z:"] as a `vector<string_view>`
| Parameter | ||
|---|---|---|
nth | size_t |