29 Numerics library [numerics]

29.10 Data-parallel types [simd]

29.10.7 Class template basic_vec [simd.class]


29.10.7.1 Overview [simd.overview]

29.10.7.2 Constructors [simd.ctor]

29.10.7.3 Subscript operator [simd.subscr]

29.10.7.4 Complex accessors [simd.complex.access]

29.10.7.5 Unary operators [simd.unary]


29.10.7.1 Overview [simd.overview]

namespace std::simd { template<class T, class Abi> class basic_vec { using real-type = see below; / exposition only public: using value_type = T; using mask_type = basic_mask<sizeof(T), Abi>; using abi_type = Abi; using iterator = simd-iterator<basic_vec>; using const_iterator = simd-iterator<const basic_vec>; constexpr iterator begin() noexcept { return {*this, 0}; } constexpr const_iterator begin() const noexcept { return {*this, 0}; } constexpr const_iterator cbegin() const noexcept { return {*this, 0}; } constexpr default_sentinel_t end() const noexcept { return {}; } constexpr default_sentinel_t cend() const noexcept { return {}; } static constexpr integral_constant<simd-size-type, simd-size-v<T, Abi>> size {}; constexpr basic_vec() noexcept = default; / [simd.ctor], basic_vec constructors template<class U> constexpr explicit(see below) basic_vec(U&& value) noexcept; template<class U, class UAbi> constexpr explicit(see below) basic_vec(const basic_vec<U, UAbi>&) noexcept; template<class G> constexpr explicit basic_vec(G&& gen); template<class R, class. Flags> constexpr basic_vec(R&& range, flags<Flags..> = {}); template<class R, class. Flags> constexpr basic_vec(R&& range, const mask_type& mask, flags<Flags..> = {}); constexpr basic_vec(const real-type& reals, const real-type& imags = {}) noexcept; / [simd.subscr], basic_vec subscript operators constexpr value_type operator[](simd-size-type) const; template<simd-integral I> constexpr resize_t<I::size(), basic_vec> operator[](const I& indices) const; / [simd.complex.access], basic_vec complex accessors constexpr real-type real() const noexcept; constexpr real-type imag() const noexcept; constexpr void real(const real-type& v) noexcept; constexpr void imag(const real-type& v) noexcept; / [simd.unary], basic_vec unary operators constexpr basic_vec& operator+() noexcept; constexpr basic_vec operator+(int) noexcept; constexpr basic_vec& operator-() noexcept; constexpr basic_vec operator-(int) noexcept; constexpr mask_type operator!() const noexcept; constexpr basic_vec operator~() const noexcept; constexpr basic_vec operator+() const noexcept; constexpr basic_vec operator-() const noexcept; / [simd.binary], basic_vec binary operators friend constexpr basic_vec operator+(const basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec operator-(const basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec operator*(const basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec operator/(const basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec operator%(const basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec operator&(const basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec operator|(const basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec operator^(const basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec operator<(const basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec operator>(const basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec operator<(const basic_vec&, simd-size-type) noexcept; friend constexpr basic_vec operator>(const basic_vec&, simd-size-type) noexcept; / [simd.cassign], basic_vec compound assignment friend constexpr basic_vec& operator+=(basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec& operator-=(basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec& operator*=(basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec& operator/=(basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec& operator%=(basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec& operator&=(basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec& operator|=(basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec& operator^=(basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec& operator<=(basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec& operator>=(basic_vec&, const basic_vec&) noexcept; friend constexpr basic_vec& operator<=(basic_vec&, simd-size-type) noexcept; friend constexpr basic_vec& operator>=(basic_vec&, simd-size-type) noexcept; / [simd.comparison], basic_vec compare operators friend constexpr mask_type operator=(const basic_vec&, const basic_vec&) noexcept; friend constexpr mask_type operator!=(const basic_vec&, const basic_vec&) noexcept; friend constexpr mask_type operator>=(const basic_vec&, const basic_vec&) noexcept; friend constexpr mask_type operator<=(const basic_vec&, const basic_vec&) noexcept; friend constexpr mask_type operator>(const basic_vec&, const basic_vec&) noexcept; friend constexpr mask_type operator<(const basic_vec&, const basic_vec&) noexcept; / [simd.cond], basic_vec exposition only conditional operators friend constexpr basic_vec simd-select-impl( / exposition only const mask_type&, const basic_vec&, const basic_vec&) noexcept; }; template<class R, class. Ts> basic_vec(R&& r, Ts..) -> see below; template<size_t Bytes, class Abi> basic_vec(basic_mask<Bytes, Abi>) -> see below; }
Every specialization of basic_vec is a complete type.
The specialization of basic_vec<T, Abi> is
  • enabled, if T is a vectorizable type, and there exists value N in the range [1, 64], such that Abi is deduce-abi-t<T, N>,
  • otherwise, disabled, if T is not a vectorizable type,
  • otherwise, it is implementation-defined if such a specialization is enabled.
If basic_vec<T, Abi> is disabled, then the specialization has a deleted default constructor, deleted destructor, deleted copy constructor, and deleted copy assignment.
In addition only the value_type, abi_type, and mask_type members are present.
If basic_vec<T, Abi> is enabled, then basic_vec<T, Abi> is trivially copyable, default-initialization of an object of such a type default-initializes all elements, and value-initialization value-initializes all elements ([dcl.init.general]).
Recommended practice: Implementations should support implicit conversions between specializations of basic_vec and appropriate implementation-defined types.
[Note 1: 
Appropriate types are non-standard vector types which are available in the implementation.
— end note]
If T is a specialization of complex, real-type denotes the same type as rebind_t<typename T​::​value_type, basic_vec<T, Abi>>, otherwise an unspecified non-array object type.

29.10.7.2 Constructors [simd.ctor]

template<class U> constexpr explicit(see below) basic_vec(U&& value) noexcept;
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_vec(const basic_vec<U, UAbi>& x) noexcept;
Effects: Initializes the
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);
Let From
Constraints: From
In addition, for all i in the range of [0, size()), if From
Effects: Initializes the
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..> = {});
Let mask be mask_type(true) for the overload with no mask parameter.
Constraints:
Mandates: 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_vec, 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
template<class R, class. Ts> basic_vec(R&& r, Ts..) -> see below;
Constraints:
Remarks: The deduced type is equivalent to vec<ranges::range_value_t<R>, static_cast<simd-size-type>(ranges::size(r))>
template<size_t Bytes, class Abi> basic_vec(basic_mask<Bytes, Abi> k) -> see below;
Constraints: basic_mask<Bytes, Abi> is an enabled specialization of basic_mask and decltype(+k) is a valid type.
Remarks: The deduced type is equivalent to decltype(+k).
constexpr basic_vec(const real-type& reals, const real-type& imags = {}) noexcept;
Effects: Initializes the

29.10.7.3 Subscript operator [simd.subscr]

constexpr value_type operator[](simd-size-type i) const;
Throws: Nothing.
template<simd-integral I> constexpr resize_t<I::size(), basic_vec> operator[](const I& indices) const;
Effects: Equivalent to: return permute(*this, indices);
constexpr real-type real() const noexcept; constexpr real-type imag() const noexcept;
Returns: An object of type real-type where the
constexpr void real(const real-type& v) noexcept; constexpr void imag(const real-type& v) noexcept;
Effects: Replaces each element of the basic_vec object such that the

29.10.7.5 Unary operators [simd.unary]

Effects in [simd.unary] are applied as unary element-wise operations.
constexpr basic_vec& operator+() noexcept;
Returns: *this.
constexpr basic_vec operator+(int) noexcept;
Returns: A copy of *this before incrementing.
constexpr basic_vec& operator-() noexcept;
Returns: *this.
constexpr basic_vec operator-(int) noexcept;
Returns: A copy of *this before decrementing.
constexpr mask_type operator!() const noexcept;
Returns: A basic_mask object with the
constexpr basic_vec operator~() const noexcept;
Returns: A basic_vec object with the
constexpr basic_vec operator+() const noexcept;
Returns: *this.
constexpr basic_vec operator-() const noexcept;
Returns: A basic_vec object where the

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant