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 explicit(see below) basic_simd(U&& value) noexcept;
Let From denote the type remove_cvref_t<U>.
Constraints: value_type satisfies constructible_from<U>.
Effects: Initializes each element to the value of the argument after conversion to value_type.
Remarks: The expression inside explicit evaluates to false if and only if U satisfies convertible_to<value_type>, and either
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);
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: gen is invoked exactly once for each i, in increasing order of i.
template<class R, class... Flags> constexpr basic_simd(R&& r, flags<Flags...> = {}); template<class R, class... Flags> constexpr basic_simd(R&& r, const mask_type& mask, flags<Flags...> = {});
Let mask be mask_type(true) for the overload with no mask parameter.
Constraints:
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(r) points to storage aligned by alignment_v<basic_simd, ranges​::​range_value_t<R>>.
  • If the template parameter pack Flags contains overaligned-flag<N>, ranges​::​data(r) points to storage aligned by N.
Effects: Initializes the element with mask[i] ? static_cast<T>(​ranges​::​​data(r)[i]) : T() for all i in the range of [0, size()).
template<class R, class... Ts> basic_simd(R&& r, Ts...) -> see below;
Constraints:
Remarks: The deduced type is equivalent to simd<ranges​::​range_value_t<R>, ranges​::​size(r)>.
template<simd-floating-point V> constexpr explicit(see below) basic_simd(const V& reals, const V& imags = {}) noexcept;
Constraints:
Effects: Initializes the element with value_type(reals[i], imags[i]) for all i in the range [0, size()).
Remarks: The expression inside explicit evaluates to false if and only if the floating-point conversion rank of T​::​value_type is greater than or equal to the floating-point conversion rank of V​::​value_type.