#include <eve/module/algo/algo/keep_if.hpp>
Defined in Header
#include <eve/module/algo.hpp>
Takes values that pass the predicate, and copies them to the beginning of the range. Values past the returned sentinel are to be considered garbage.
Acts like an eager version of filter, or an in-place version of std::copy_if:
std::copy_if(r.begin(), r.end(), r.begin(), predicate);
- Note
- If you need to apply a transformation, you can use eve::algo::views::map or eve::algo::transform_keep_if.
Tuning
::dense_output/::sparse_output: if you expect very sparse output (one or two trues per register), you can call ::keep_if[::sparse_output](...) to optimize for that scenario.
{
template<relaxed_range Rng, typename P>
}
unaligned_t< iterator_t< R > > unaligned_iterator_t
Unaligned iterator for a relaxed range.
Definition ranges_types.hpp:68
constexpr auto keep_if
In-place version of std::copy_if.
Definition keep_if.hpp:118
Parameters
- rng: Range to modify
- p: SIMD predicate over elements of rng
Return value
Iterator past the last written element.
- See also
- copy_if
-
remove_if
-
transform_keep_if
-
transform_copy_if