Files
2025-10-25 03:02:53 +03:00

8.9 KiB
Raw Permalink Blame History

[simd.ctor]

29 Numerics library [numerics]

29.10 Data-parallel types [simd]

29.10.7 Class template basic_vec [simd.class]

29.10.7.2 basic_vec constructors [simd.ctor]

🔗

template<class U> constexpr explicit(see below) basic_vec(U&& value) noexcept;

1

#

Let From denote the type remove_cvref_t.

2

#

Constraints: value_type satisfies constructible_from.

3

#

Effects: Initializes each element to the value of the argument after conversion tovalue_type.

4

#

Remarks: The expression inside explicit evaluates to false if and only ifU satisfies convertible_to<value_type>, and either

From is not an arithmetic type and does not satisfy constexpr-wrapper-like,

From is an arithmetic type and the conversion from From to value_type is value-preserving ([simd.general]), or

From satisfies constexpr-wrapper-like, remove_const_t<decltype(From::value)> is an arithmetic type, and From::value is representable by value_type.

🔗

template<class U, class UAbi> constexpr explicit(see below) basic_vec(const basic_vec<U, UAbi>& x) noexcept;

5

#

Constraints: simd-size-v<U, UAbi> == size() is true.

6

#

Effects: Initializes the ith element with static_cast(x[i]) for all i in the range of [0, size()).

7

#

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_vec(G&& gen);

8

#

Let Fromi denote the typedecltype(gen(integral_constant<simd-size-type, i>())).

9

#

Constraints: Fromi 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 Fromi is an arithmetic type, conversion from Fromi to value_type is value-preserving.

10

#

Effects: Initializes the ith element withstatic_cast<value_type>(gen(integral_constant<simd-size-type, i>())) for all i in the range of [0, size()).

11

#

Remarks: gen is invoked exactly once for each i, in increasing order of i.

🔗

template<class R, class... Flags> constexpr basic_vec(R&& r, flags<Flags...> = {}); template<class R, class... Flags> constexpr basic_vec(R&& r, const mask_type& mask, flags<Flags...> = {});

12

#

Let mask be mask_type(true) for the overload with nomask parameter.

13

#

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().

14

#

Mandates:

ranges::range_value_t is a vectorizable type, and

if the template parameter pack Flags does not contain convert-flag, then the conversion from ranges::range_value_t to value_type is value-preserving.

15

#

Preconditions:

  • (15.1)

    If the template parameter pack Flags contains aligned-flag, ranges::data(r) points to storage aligned by alignment_v<basic_vec, ranges::range_value_t>.

  • (15.2)

    If the template parameter pack Flags contains overaligned-flag, ranges::data(r) points to storage aligned by N.

16

#

Effects: Initializes the ith element with mask[i] ?static_cast(ranges::data(r)[i]) : T() for all i in the range of [0, size()).

🔗

template<class R, class... Ts> basic_vec(R&& r, Ts...) -> see below;

17

#

Constraints:

R models ranges::contiguous_range and ranges::sized_range, and

ranges::size(r) is a constant expression.

18

#

Remarks: The deduced type is equivalent to vec<ranges::range_value_t, ranges::size(r)>.

🔗

template<[simd-floating-point](simd.expos#concept:simd-floating-point "29.10.2Exposition-only types, variables, and concepts[simd.expos]") V> constexpr explicit(see below) basic_vec(const V& reals, const V& imags = {}) noexcept;

19

#

Constraints:

simd-complex<basic_vec> is modeled, and

V::size() == size() is true.

20

#

Effects: Initializes the ith element with value_type(reals[i], imags[i]) for all i in the range [0, size()).

21

#

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.