◆ broadcast()

template<std::size_t Index, typename Value >
Value boost::simd::broadcast ( Value const &  v)

Returns a boost::simd::pack filled with the value of the N th value of its argument.

Header <boost/simd/function/broadcast.hpp>
Scalar Semantic:
For any value v of type T and any integral constant I, the following code:
T r = boost::simd::broadcast<I>(v);

is equivalent to:

T r = I == 0 ? static_cast<T>(v) : T{0};
SIMD Semantic:
For any type T and any integral constants N and I, the following code:
pack<T,N> r = boost::simd::broadcast<I>(v);

is equivalent to:

pack<T,N> r{ ((I < N) || (I>=0)) ? v[I] : 0};

The extraction of the value is done using the optimal intrinsics if available or will proceed to a memory read-back. See boost::simd::extract for more informations.

Template Parameters
Indexindex of the value to broadcast
Parameters
vregister to broadcast value from
Returns
A boost::simd::pack filled with the Index value of v