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

◆ copy

auto eve::algo::copy = function_with_traits<copy_>[default_simple_algo_traits]
inlineconstexpr

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

Configurable Callable Object performing a SIMD optimized version of the copy. By default, the operation will be unrolled by a factor of 4, align memory accesses and perform conversions if needed.

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

Alternative Header

#include <eve/algo.hpp>

Callable Signatures

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

Parameters

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

Example

#include <eve/module/algo.hpp>
#include <tts/tts.hpp>
#include <iostream>
#include <vector>
int main()
{
std::vector<double> from_vector = {2.5,6.8,-10.62,3.2,-8.8,2.7,-6.66,8.5,-2.01,4.8};
std::vector<double> to_vector(from_vector.size());
std::vector<double> to_vector_z(from_vector.size());
std::cout << "from_vector = "
<< tts::as_string(from_vector)
<< "\n";
eve::algo::copy(from_vector, to_vector);
std::cout << "to_vector = "
<< tts::as_string(to_vector)
<< "\n";
eve::algo::copy( eve::algo::views::zip(from_vector, to_vector_z) );
std::cout << "to_vector (zip) = "
<< tts::as_string(to_vector_z)
<< "\n";
return 0;
}
constexpr auto zip
Given relaxed_iterors and relaxed ranges, zips them together (creates a single object)....
Definition zip.hpp:144