STD::VALARRAY(3cxx)

πŸ’– NAME πŸ’–

Okay so bestie, this is std::valarray< _Tp > from manual section 3cxx β€” the smart array designed to support numeric processing ✨. That's the name and the whole vibe, periodt πŸ’….

✨ SYNOPSIS ✨

#include <valarray>

πŸŽ€ Public Types πŸŽ€

  • typedef _Tp value_type β€” the value type of the array, no cap πŸ’–

πŸ‘‘ Public Member Functions πŸ‘‘

This is the full member-function roster, bestie β€” every overload is invited to the group chat πŸ’….

  • valarray () noexcept β€” constructs an empty array. Empty-array main character energy 🫢
  • template<class _Dom > valarray (const _Expr< _Dom, _Tp > &__e) β€” the _Expr constructor overload; the manual gives no extra one-liner here, but it's on the list and it counts 🌸
  • valarray (const _Tp &, size_t) β€” constructs an array with n elements initialized to t ✨
  • template<typename _Tp > valarray (const _Tp *__restrict__ __p, size_t __n) β€” the pointer-plus-size template constructor; manual has no extra description, but we are not leaving it out πŸ“Œ
  • valarray (const _Tp *__restrict__, size_t) β€” constructs an array initialized to the first n elements of t β€” pointer girlie behavior 🌸
  • valarray (const gslice_array< _Tp > &) β€” constructs an array with the same size and values in ga πŸŽ€
  • valarray (const indirect_array< _Tp > &) β€” constructs an array with the same size and values in ia πŸ¦‹
  • valarray (const mask_array< _Tp > &) β€” constructs an array with the same size and values in ma πŸ’œ
  • valarray (const slice_array< _Tp > &) β€” constructs an array with the same size and values in sa 🌈
  • valarray (const valarray &) β€” copy constructor. Copy-paste but make it classy πŸ’…
  • valarray (initializer_list< _Tp >) β€” constructs an array with an initializer_list of values πŸ“
  • valarray (size_t) β€” constructs an array with n elements ✨
  • valarray (valarray &&) noexcept β€” move constructor. Bye, but make it official πŸ‘‹
  • _Expr< _ValFunClos< _ValArray, _Tp >, _Tp > apply (_Tp __func(_Tp)) const β€” apply a function to the array 🫢
  • _Expr< _RefFunClos< _ValArray, _Tp >, _Tp > apply (_Tp __func(const _Tp &)) const β€” apply a function to the array, but this overload takes const _Tp & πŸ’…
  • valarray< _Tp > cshift (int __n) const β€” returns a rotated array β€” circular shift slay πŸŒ€
  • _Tp max () const β€” returns the maximum element using operator<() πŸ‘‘
  • _Tp min () const β€” returns the minimum element using operator<() πŸ₯Ί
  • _UnaryOp< __logical_not >::_Rt operator! () const β€” returns a new valarray by applying unary ! to each element 😭
  • template<class _Dom > valarray< _Tp > & operator%= (const _Expr< _Dom, _Tp > &) β€” the _Expr overload for %=; no extra description in the manual, but it's still invited πŸ’…
  • valarray< _Tp > & operator%= (const _Tp &) β€” sets each element e of array to e % t ✨
  • valarray< _Tp > & operator%= (const valarray< _Tp > &) β€” modulo elements of array by corresponding elements of v πŸ”’
  • template<class _Dom > valarray< _Tp > & operator&= (const _Expr< _Dom, _Tp > &) β€” the _Expr overload for &=; manual leaves this one description-less, we respect the mystery 🫢
  • valarray< _Tp > & operator&= (const _Tp &) β€” sets each element e of array to e & t ✨
  • valarray< _Tp > & operator&= (const valarray< _Tp > &) β€” logical and corresponding elements of v with elements of array πŸ’œ
  • template<class _Dom > valarray< _Tp > & operator*= (const _Expr< _Dom, _Tp > &) β€” the _Expr overload for *=; no extra blurb in the original, but it's on the roster πŸ’…
  • valarray< _Tp > & operator*= (const _Tp &) β€” multiply each element of array by t βœ–οΈ
  • valarray< _Tp > & operator*= (const valarray< _Tp > &) β€” multiply elements of array by corresponding elements of v πŸ”₯
  • _UnaryOp< __unary_plus >::_Rt operator+ () const β€” returns a new valarray by applying unary + to each element ✨
  • template<class _Dom > valarray< _Tp > & operator+= (const _Expr< _Dom, _Tp > &) β€” the _Expr overload for +=; no extra description, still iconic πŸ‘‘
  • valarray< _Tp > & operator+= (const _Tp &) β€” add t to each element of array βž•
  • valarray< _Tp > & operator+= (const valarray< _Tp > &) β€” add corresponding elements of v to elements of array 🫢
  • _UnaryOp< __negate >::_Rt operator- () const β€” returns a new valarray by applying unary - to each element πŸ’…
  • template<class _Dom > valarray< _Tp > & operator-= (const _Expr< _Dom, _Tp > &) β€” the _Expr overload for -=; manual has no extra one-liner, but it's here 🫢
  • valarray< _Tp > & operator-= (const _Tp &) β€” subtract t from each element of array βž–
  • valarray< _Tp > & operator-= (const valarray< _Tp > &) β€” subtract corresponding elements of v from elements of array πŸ’œ
  • template<class _Dom > valarray< _Tp > & operator/= (const _Expr< _Dom, _Tp > &) β€” the _Expr overload for /=; no extra description in the manual, but it's not getting left out 🌸
  • valarray< _Tp > & operator/= (const _Tp &) β€” divide each element of array by t βž—
  • valarray< _Tp > & operator/= (const valarray< _Tp > &) β€” divide elements of array by corresponding elements of v πŸ”’
  • template<class _Dom > valarray< _Tp > & operator<<= (const _Expr< _Dom, _Tp > &) β€” the _Expr overload for <<=; manual leaves it description-less, we still love her πŸ’…
  • valarray< _Tp > & operator<<= (const _Tp &) β€” left shift each element e of array by t bits ⬅️
  • valarray< _Tp > & operator<<= (const valarray< _Tp > &) β€” left shift elements of array by corresponding elements of v ✨
  • template<class _Dom > valarray< _Tp > & operator= (const _Expr< _Dom, _Tp > &) β€” the _Expr assignment overload; no extra description in the manual, but it's on the list 🫢
  • valarray< _Tp > & operator= (const _Tp &__t) β€” assign elements to a value ✨
  • valarray< _Tp > & operator= (const gslice_array< _Tp > &__ga) β€” assign elements to an array subset πŸŽ€
  • valarray< _Tp > & operator= (const indirect_array< _Tp > &__ia) β€” assign elements to an array subset πŸ¦‹
  • valarray< _Tp > & operator= (const mask_array< _Tp > &__ma) β€” assign elements to an array subset πŸ’œ
  • valarray< _Tp > & operator= (const slice_array< _Tp > &__sa) β€” assign elements to an array subset 🌈
  • valarray< _Tp > & operator= (const valarray< _Tp > &__v) β€” assign elements to an array πŸ’…
  • valarray & operator= (initializer_list< _Tp > __l) β€” assign elements to an initializer_list πŸ“
  • valarray< _Tp > & operator= (valarray< _Tp > &&__v) noexcept β€” move assign elements to an array πŸ’¨
  • template<class _Dom > valarray< _Tp > & operator>>= (const _Expr< _Dom, _Tp > &) β€” the _Expr overload for >>=; no extra description in the original, but she's here πŸ’…
  • valarray< _Tp > & operator>>= (const _Tp &) β€” right shift each element e of array by t bits ➑️
  • valarray< _Tp > & operator>>= (const valarray< _Tp > &) β€” right shift elements of array by corresponding elements of v ✨
  • gslice_array< _Tp > operator[] (const gslice &__s) β€” return a reference to an array subset πŸŽ€
  • _Expr< _GClos< _ValArray, _Tp >, _Tp > operator[] (const gslice &__s) const β€” return an array subset ✨
  • mask_array< _Tp > operator[] (const valarray< bool > &__m) β€” return a reference to an array subset πŸ’œ
  • valarray< _Tp > operator[] (const valarray< bool > &__m) const β€” return an array subset πŸ¦‹
  • indirect_array< _Tp > operator[] (const valarray< size_t > &__i) β€” return a reference to an array subset 🌈
  • _Expr< _IClos< _ValArray, _Tp >, _Tp > operator[] (const valarray< size_t > &__i) const β€” return an array subset ⭐
  • _Tp & operator[] (size_t __i) noexcept β€” no extra description in the manual, but it's the size_t reference access and it's here πŸ’…
  • const _Tp & operator[] (size_t) const noexcept β€” no extra description, const size_t access, still iconic πŸ‘‘
  • slice_array< _Tp > operator[] (slice __s) β€” return a reference to an array subset 🌸
  • _Expr< _SClos< _ValArray, _Tp >, _Tp > operator[] (slice __s) const β€” return an array subset 🧚
  • template<class _Dom > valarray< _Tp > & operator^= (const _Expr< _Dom, _Tp > &) β€” the _Expr overload for ^=; no extra description in the manual, but it stays πŸ’…
  • valarray< _Tp > & operator^= (const _Tp &) β€” set each element e of array to e ^ t ✨
  • valarray< _Tp > & operator^= (const valarray< _Tp > &) β€” logical xor corresponding elements of v with elements of array πŸ”₯
  • template<class _Dom > valarray< _Tp > & operator|= (const _Expr< _Dom, _Tp > &) β€” the _Expr overload for |=; manual gives no extra one-liner, still invited 🫢
  • valarray< _Tp > & operator|= (const _Tp &) β€” set each element e of array to e | t ✨
  • valarray< _Tp > & operator|= (const valarray< _Tp > &) β€” logical or corresponding elements of v with elements of array πŸ’œ
  • _UnaryOp< __bitwise_not >::_Rt operator~ () const β€” returns a new valarray by applying unary ~ to each element πŸ’…
  • void resize (size_t __size, _Tp __c=_Tp()) β€” resize array. The default for __c is _Tp() 🫢
  • valarray< _Tp > shift (int __n) const β€” return a shifted array 🌸
  • size_t size () const β€” return the number of elements in array πŸ”’
  • _Tp sum () const β€” return the sum of all elements in the array βž•
  • void swap (valarray< _Tp > &__v) noexcept β€” swap. Periodt πŸ’…

πŸ¦‹ Friends πŸ¦‹

  • struct _Array< _Tp > β€” friend struct, no extra description in the manual; it's in the friend list, bestie 🫢

πŸ’– Detailed Description πŸ’–

template<class _Tp>
class std::valarray< _Tp >"Smart array designed to support numeric processing.

Okay so a valarray is an array that provides constraints intended to allow for effective optimization of numeric array processing by reducing the aliasing that can result from pointer representations. It represents a one-dimensional array from which different multidimensional subsets can be accessed and modified. Slay, honestly πŸ’….

🌈 Template Parameters 🌈

  • _Tp β€” Type of object in the array. That's the template parameter, bestie ✨

🧚 Constructor & Destructor Documentation 🧚

template<class _Tp > std::valarray< _Tp >::valarray (const _Tp *
       __restrict__, size_t)

Construct an array initialized to the first n elements of t β€” constructor documentation, but make it cute 🌸.

πŸ’– Member Function Documentation πŸ’–

okay bestie, this is the part where all the operators live β€” every single one of them, and yes there are a LOT, so buckle up πŸŽ€. Two flavours of almost everything: one that takes a single value t (scalar mode, it hits every element) and one that takes another valarray v (element-by-element mode, position by position). Keep your eyes on which is which, iykyk ✨


  • template<class _Tp > _UnaryOp< __logical_not >::_Rt std::valarray< _Tp >::operator! () const β€” bestie this one doesn't touch the original at all, it hands you back a brand new valarray made by applying unary ! to each element πŸ‘‘
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator%= (const _Tp &) β€” set each element e of array to e % t πŸ“
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator%= (const valarray< _Tp > &) β€” modulo the elements of array by the corresponding elements of v, literally matchy-matchy πŸ’…
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator&= (const _Tp &) β€” set each element e of array to e & t 🌸
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator&= (const valarray< _Tp > &) β€” logical and the corresponding elements of v with the elements of array, no cap ✨
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator*= (const _Tp &) β€” multiply each element of array by t πŸ”₯
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator*= (const valarray< _Tp > &) β€” multiply the elements of array by the corresponding elements of v πŸ¦‹
  • template<class _Tp > _UnaryOp< __unary_plus >::_Rt std::valarray< _Tp >::operator+ () const β€” returns a whole new valarray, built by applying unary + to each element, main character energy πŸ‘‘
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator+= (const _Tp &) β€” add t to each element of array ⭐
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator+= (const valarray< _Tp > &) β€” add the corresponding elements of v to the elements of array, cute and paired πŸ’œ
  • template<class _Tp > _UnaryOp< __negate >::_Rt std::valarray< _Tp >::operator- () const β€” new valarray, unary - applied to every element, iconic 😭
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator-= (const _Tp &) β€” subtract t from each element of array 🌈
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator-= (const valarray< _Tp > &) β€” subtract the corresponding elements of v from the elements of array πŸŽ€
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator/= (const _Tp &) β€” divide each element of array by t πŸ™ˆ
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator/= (const valarray< _Tp > &) β€” divide the elements of array by the corresponding elements of v πŸ’€
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator<<= (const _Tp &) β€” left shift each element e of array by t bits 🧚
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator<<= (const valarray< _Tp > &) β€” left shift the elements of array by the corresponding elements of v ⭐
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator>>= (const _Tp &) β€” right shift each element e of array by t bits 🫢
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator>>= (const valarray< _Tp > &) β€” right shift the elements of array by the corresponding elements of v πŸ¦‹
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator^= (const _Tp &) β€” set each element e of array to e ^ t πŸ”₯
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator^= (const valarray< _Tp > &) β€” logical xor the corresponding elements of v with the elements of array πŸ’…
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator|= (const _Tp &) β€” set each element e of array to e | t 🌸
  • template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator|= (const valarray< _Tp > &) β€” logical or the corresponding elements of v with the elements of array, periodt πŸ‘‘
  • template<class _Tp > _UnaryOp< __bitwise_not >::_Rt std::valarray< _Tp >::operator~ () const β€” last one bestie!! returns a fresh new valarray by applying unary ~ to each element πŸŽ€βœ¨
lowkey notice that the unary ones (!, +, -, ~) are const and give you back a new valarray, while the compound-assignment ones (%=, &=, *=, +=, -=, /=, <<=, >>=, ^=, |=) hand you back a valarray< _Tp > & and mutate in place. vibe check passed πŸ’–

🌟 Author 🌟

Generated automatically by Doxygen for libstdc++ from the source code. yes bestie, a robot wrote this one, not me β€” I just gave it the group-chat glow-up πŸ’«


and that's the whole page, we ate and left zero crumbs πŸ“ this little beauty comes to you courtesy of libstdc++, and it's the std::valarray< _Tp >(3cxx) page β€” go forth and vectorize your little heart out, ily, bye πŸ’œπŸ¦‹πŸŽ€

πŸ“¦ where this page comes from