◆ copy()

template<typename T >
T* boost::simd::copy ( T const *  first,
T const *  last,
T *  out 
)

Copies the elements in the range, defined by [first, last) to another range beginning at out.

Parameters
firstBeginning of the range of elements
lastEnd of the range of elements
outBeginning of the destination range
Requirement
  • first, last and out must be pointer to Vectorizable type.
  • return a pointer to the element past the last element copied.
Example:
#include <boost/simd/algorithm/copy.hpp>
#include <boost/simd/pack.hpp>
#include <iostream>
#include <vector>
#include <iterator>
int main()
{
namespace bs = boost::simd;
std::vector<float> d{ 0.0f, 2.0f, 0.0f, 0.0f, -1.0f, 2.0f, 0.0f, 2.0f, -1.0f, 2.0f, 0.0f, 2.0f};
for(std::size_t i=0; i < boost::simd::pack < float>::static_size; ++i)
{
std::vector<float> o(7);
auto r1 = bs::copy( d.data()+i, d.data()+i+7, o.data() );
std::cout << "d = (" ;
for( auto e : o) std::cout << e << " ";
std::cout << ") " << std::endl;
std::cout << "nb copied " << std::distance(o.data(), r1) << "\n";
}
return 0;
}
Possible output:
d = (0 2 0 0 -1 2 0 )
nb copied 7
d = (2 0 0 -1 2 0 2 )
nb copied 7
d = (0 0 -1 2 0 2 -1 )
nb copied 7
d = (0 -1 2 0 2 -1 2 )
nb copied 7