◆ aligned_store()

template<typename Value , typename Pointer , typename Offset , typename Mask >
void boost::simd::aligned_store ( Value const &  val,
Pointer const &  ptr,
Offset const &  offset,
Mask const &  mask 

Store a value at an aligned memory location.

Store a given value into an aligned memory location referenced by either a pointer or a pointer and an offset. To support SIMD idioms like data scattering or non-POD values, both Pointer and Offset arguments can themselves be SIMD register or Fusion Sequences.

Header <boost/simd/function/aligned_store.hpp>

Depending on the type of its arguments, store exhibits different semantics. For any x of type Value, ptr of type Pointer, offset of type Offset and mask of type Mask, consider:


If x is a SIMD value, this code is equivalent to:

  • If offset is a scalar integer:
for(int i=0;i<Value::static_size;++i)
if mask[i]
*(ptr+offset+i) = x[i];
  • If offset is a SIMD integral register:
for(int i=0;i<Value::static_size;++i)
if mask[i]
*(ptr+offset[i]) = x[i];

In this case, the store operation is equivalent to a scatter operation.

If x and ptr are Fusion Sequences of size N, this code is equivalent to:


If x is a scalar value, this code is equivalent to:

if (mask)
*(ptr+offset) = x;

If Type is a SIMD register type:

is_aligned( ptr + offset - Misalignment )

evaluates to true

valValue to store
ptrMemory location to store val to
offsetOptional memory offset.
maskOptional logical mask. Only stores values for which the mask is true.