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

◆ copy_backward

eve::algo::copy_backward = function_with_traits<copy_backward_>[default_simple_algo_traits]
inlineconstexpr

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

Configurable Callable Object performing backward copy between two ranges' or between a range and an iterator.

By default, eve::algo::copy_backward will be unrolled by a factor of 4, align memory accesses and perform conversions if needed.

Note
If you want to copy between ranges of the same scalar type, use std::memmove.

Alternative Header

#include <eve/algo.hpp>

Callable Signatures

namespace eve::algo
{
template<typename R1, typename R2>
void copy_backward(R1&& r1, R2&& r2) requires zip_to_range<R1, R2>; // 1
void copy_backward(zipped_range_pair auto&& r); // 2
}
constexpr auto copy_backward
SIMD optimized backward copy algorithm.
Definition: copy.hpp:153
  1. Copy the elements of from r1 to r2.
  2. Copy the elements of from get<0>(r) to get<1>(r).

The elements are copied in reverse order (the last element is copied first), but their relative order is preserved. Due to the specificities of the SIMD algorithm, the second can not be an iterator. Use the zip based overload to do so.

Parameters

  • r1 : The range of elements or an iterator to the beginning of the elements to copy from
  • r2 : A range of the destination elements
  • r : A eve::algo::zipped_range_pair of ranges and/or iterators.

Example

#include <eve/module/algo.hpp>
#include <eve/module/algo.hpp>
#include <tts/tts.hpp>
#include <iostream>
#include <vector>
int main()
{
std::vector<int> from_vector = {1,2,3,4,5,6,7,8,9,10};
std::vector<int> to_vector(15);
eve::algo::copy_backward(from_vector, eve::algo::as_range(to_vector.end()-10, to_vector.end()) );
std::cout << "from_vector = "
<< tts::as_string(from_vector)
<< "\n";
std::cout << "from_vector = "
<< tts::as_string(to_vector)
<< "\n";
}