std::experi...md::copy_to(3)
π NAME π
std::experimental::simd::copy_to β okay bestie, the name is literally std::experimental::simd::copy_to, and itβs also std::experimental::simd::copy_to again. We love a self-referential icon. This is the std::experi...md::copy_to(3) page from the C++ Standard Libary manual. β¨
β¨ Synopsis β¨
template< class U, class Flags > (parallelism TS v2)
void copy_to( U* mem, Flags flags );
The store function copies all elements of a simd such that the i-th element is converted to U and subsequently written to mem[i] for all i in the range of [0, size()). Thatβs the whole vibe. π
πΈ Parameters πΈ
memβ a pointer into an array where[mem, mem + size())is a valid range. Keep that range valid, periodt. π«Άflagsβ if of typevector_aligned_tag, the load constructor may assumememto point to storage aligned bymemory_alignment_v<simd, U>.
yes bestie, it really says βload constructorβ on a store function β we donβt ask questions, we just keep the text exactly as it is π
π¦ Type requirements π¦
Umust be a vectorizable type.is_simd_flag_type_v<Flags>must be true.
No cap, those have to hold. β
π Example π
// Run this code
#include <experimental/simd>
#include <iostream>
namespace stdx = std::experimental;
int main()
{
alignas(stdx::memory_alignment_v<stdx::native_simd<int>>)
std::array<int, stdx::native_simd<int>::size()> mem = {};
stdx::native_simd<int> a = 7;
a.copy_to(&mem[0], stdx::vector_aligned);
for (int e : mem)
std::cout << e << ' ';
std::cout << '\n';
}
π Possible output: π
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
π See also π
element_aligned_tagβ flag indicating alignment of the load/store address to element;element_alignedβ alignment; (parallelism TS v2) (class)vector_aligned_tagβ flag indicating alignment of the load/store address to vector;vector_alignedβ alignment; (parallelism TS v2) (class)overaligned_tagβ flag indicating alignment of the load/store address to the;overalignedβ specified alignment; (parallelism TS v2) (class template)memory_alignmentβ obtains an appropriate alignment forvector_aligned; (parallelism TS v2) (class template)copy_fromβ loads simd elements from contiguous memory; (parallelism TS v2) (public member function)
okay bestie, thatβs the whole page π sourced from http://cppreference.com, version/date 2024.06.10. go off and copy those simd elements with main character energy β¨π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms