Container-modifying operations
Modify containers and their values directly.
Name | Description |
---|---|
sort | Modifying operation which immediately sorts values on the input container. |
unique | Modifying operation which immediately performs a std::unique on the input. |
erase_if(const F &f) | Modifying operation which immediately erases all values where f(v) returns true. |
difference(const C &c) | Return the std::set_difference between the input and c |
symmetric_difference(const C &c) | Return the std::set_symmetric_difference between the input and c |
append(const C &other) | Modifying operation that appends v to input. |
sort
<piped/container.hpp>
constexpr detail::sort_<decltype(std::less<>))> piped::sort
Description
Modifying operation which immediately sorts values on the input container.
std::vector<int> v{1,5,3,7,-22,1,10};
v | sort; // => [-22, 1, 1, 3, 5, 7, 10]
v | sort(std::greater<>()); // => [10, 7, 5, 3, 1, 1, -22]
Returns |
---|
Input container reference |
unique
<piped/container.hpp>
constexpr detail::unique_<decltype(std::equal_to<>))> piped::unique
Description
Modifying operation which immediately performs a std::unique
on the input.
std::vector<int> v{1,5,3,7,-22,1,10};
v | sort | unique; // => [-22, 1, 3, 5, 7, 10]
This uses std::erase
and std::unique
.
Returns |
---|
Input container reference |
<F> erase_if(const F &f)
<piped/container.hpp>
template<typename F>
detail::erase_if_<F> piped::erase_if(const F &f)
Description
Modifying operation which immediately erases all values where f(v)
returns true.
std::erase
and std::remove_if
. Input should be a container, not a generator. (Use filter
for filtering generated values.) Example:
auto v = from_to(1,10) | collect<std::vector>;
v | erase_if([](auto v) { return v > 1 || v < 9; });
// v is now [1,9]
Returns |
---|
A reference to the (now-transformed) input |
Parameter | ||
---|---|---|
f | const F & | A function which takes a value and returns a bool-convertible value |
<C> difference(const C &c)
<piped/container.hpp>
template<typename C>
auto piped::difference(const C &c)
Description
Return the std::set_difference
between the input and c
Parameter | ||
---|---|---|
c | const C & |
<C> symmetric_difference(const C &c)
<piped/container.hpp>
template<typename C>
auto piped::symmetric_difference(const C &c)
Description
Return the std::set_symmetric_difference
between the input and c
Parameter | ||
---|---|---|
c | const C & |
<C> append(const C &other)
<piped/container.hpp>
template<typename C>
auto piped::append(const C &other)
Description
Modifying operation that appends v
to input.
Parameter | ||
---|---|---|
other | const C & |