E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ copy_if

auto eve::algo::copy_if = function_with_traits<copy_if_>
inlineconstexpr

#include <eve/module/algo/algo/copy_if.hpp>

Defined in Header

#include <eve/module/algo.hpp>
Note
If you need to apply a transformation, you can use eve::algo::views::map or eve::algo::transform_copy_if.

The main difference from std::copy_if is that it accepts output range and not an output iterator. If the output doesn't have enough space, algorithm will fill all of the avaliable output and then stop. The interface difference allows eve to store more then just selected elements which is important for efficiency.

Note
fix-1656: unfortunately at the moment, we only return where writing output finished. We should return where the input stopped too but we couldn't solve that efficiently so far.

Tuning:

  • eve::algo::dense_output/evealgo::sparse_output - if you expect very sparse output (one or two trues per register) - you can pass sparse_output to try to optimize for that.
  • Does not support unrolling at the moment. In the exepriments with compress it didn't prove beneficial, but you can always try with eve::algo::for_each, assuming you can overallocate the output.
  • Algorithm switches to a much slower version, when there is not enough space to write a full register. Allocating more than input size won't help though.

Callable Signatures

namespace eve::algo
{
template<relaxed_range In, relaxed_range Out, typename P>
auto copy_if(In&& in, Out&& out, P p) -> unaligned_iterator_t<Out>
}
unaligned_t< iterator_t< R > > unaligned_iterator_t
Unaligned iterator for a relaxed range.
Definition ranges_types.hpp:68
constexpr auto copy_if
SIMD variation on std::copy_if.
Definition copy_if.hpp:149

** Parameters **

** Return value **

relaxed_iterator past the last written element.

See also
keep_if
remove_if
transform_keep_if
transform_copy_if