29 Numerics library [numerics]

29.10 Data-parallel types [simd]

29.10.6 Class template basic_simd [simd.class]

29.10.6.2 basic_simd constructors [simd.ctor]

template<class U> constexpr basic_simd(U&&) noexcept;
Let From denote the type remove_cvref_t<U>.
Constraints: From satisfies convertible_to<value_type>, and either
Effects: Initializes each element to the value of the argument after conversion to value_type.
template<class U, class UAbi> constexpr explicit(see below) basic_simd(const basic_simd<U, UAbi>& x) noexcept;
Constraints: simd-size-v<U, UAbi> == size() is true.
Effects: Initializes the element with static_cast<T>(x[i]) for all i in the range of [0, size()).
Remarks: The expression inside explicit evaluates to true if either
  • the conversion from U to value_type is not value-preserving, or
  • both U and value_type are integral types and the integer conversion rank ([conv.rank]) of U is greater than the integer conversion rank of value_type, or
  • both U and value_type are floating-point types and the floating-point conversion rank ([conv.rank]) of U is greater than the floating-point conversion rank of value_type.
template<class G> constexpr explicit basic_simd(G&& gen) noexcept;
Let From denote the type decltype(gen(integral_constant<simd-size-type, i>())).
Constraints: From satisfies convertible_to<value_type> for all i in the range of [0, size()).
In addition, for all i in the range of [0, size()), if From is an arithmetic type, conversion from From to value_type is value-preserving.
Effects: Initializes the element with static_cast<value_type>(gen(integral_constant<simd-​size-​type, i>())) for all i in the range of [0, size()).
Remarks: The calls to gen are unsequenced with respect to each other.
Vectorization-unsafe ([algorithms.parallel.defns]) standard library functions may not be invoked by gen.
gen is invoked exactly once for each i.
template<class R, class... Flags> constexpr basic_simd(R&& r, simd_flags<Flags...> = {}); template<class R, class... Flags> constexpr basic_simd(R&& r, const mask_type& mask, simd_flags<Flags...> = {});
Let mask be mask_type(true) for the overload with no mask parameter.
Constraints:
  • R models ranges​::​contiguous_range and ranges​::​sized_range,
  • ranges​::​size(r) is a constant expression, and
  • ranges​::​size(r) is equal to size().
Mandates:
  • ranges​::​range_value_t<R> is a vectorizable type, and
  • if the template parameter pack Flags does not contain convert-flag, then the conversion from ranges​::​range_value_t<R> to value_type is value-preserving.
Preconditions:
  • If the template parameter pack Flags contains aligned-flag, ranges​::​data(range) points to storage aligned by simd_alignment_v<basic_simd, ranges​::​range_value_t<R>>.
  • If the template parameter pack Flags contains overaligned-flag<N>, ranges​::​data(range) points to storage aligned by N.
Effects: Initializes the element with mask[i] ? static_cast<T>(​ranges​::​​data(range)[i]) : T() for all i in the range of [0, size()).
template<class R, class... Ts> basic_simd(R&& r, Ts...) -> see below;
Constraints:
  • R models ranges​::​contiguous_range and ranges​::​sized_range, and
  • ranges​::​size(r) is a constant expression.
Remarks: The deduced type is equivalent to simd<ranges​::​range_value_t<R>, ranges​::​size(r)>.