STD::VALARRAY(3)

πŸ’– std::valarray< _Tp > πŸ’–

Library Functions Manual Β· section 3

okay so bestie, sit down, hydrate, because today we are talking about std::valarray< _Tp >, and she is that girl. this is the manual page for the smart array that the C++ standard library built specifically for numeric processing. no cap. πŸŽ€


✨ NAME ✨

std::valarray< _Tp > β€” Smart array designed to support numeric processing.

she's literally described as smart. the bar is on the floor and she cleared it. πŸ’…


🌸 SYNOPSIS 🌸

#include <valarray>

πŸ¦‹ Public Types πŸ¦‹

  • typedef _Tp value_type β€” the type of the stuff living inside her. iconique.

πŸ’œ Public Member Functions πŸ’œ

okay this is the big one, the main event, the reason we're all here. strap in. 🌈

  • valarray () noexcept β€” Construct an empty array. she starts with nothing and that's valid.
  • template<class _Dom> valarray (const _Expr< _Dom, _Tp > &__e) β€” the docs gave this one no description at all, so she's keeping it mysterious. πŸ™ˆ
  • valarray (const _Tp &, size_t) β€” Construct an array with n elements initialized to t.
  • template<typename _Tp> valarray (const _Tp *__restrict__ __p, size_t __n) β€” no description here either. enigmatic queen. πŸ’€
  • valarray (const _Tp *__restrict__, size_t) β€” Construct an array initialized to the first n elements of t.
  • valarray (const gslice_array< _Tp > &) β€” Construct an array with the same size and values in ga.
  • valarray (const indirect_array< _Tp > &) β€” Construct an array with the same size and values in ia.
  • valarray (const mask_array< _Tp > &) β€” Construct an array with the same size and values in ma.
  • valarray (const slice_array< _Tp > &) β€” Construct an array with the same size and values in sa.
  • valarray (const valarray &) β€” Copy constructor. making a whole new her, fr fr.
  • valarray (initializer_list< _Tp >) β€” Construct an array with an initializer_list of values.
  • valarray (size_t) β€” Construct an array with n elements.
  • valarray (valarray &&) noexcept β€” Move constructor. she's moving out, no drama, noexcept. 🫢
  • _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.
  • valarray< _Tp > cshift (int __n) const β€” Return a rotated array.
  • _Tp max () const β€” Return the maximum element using operator<().
  • _Tp min () const β€” Return the minimum element using operator<().
  • _UnaryOp< __logical_not >::_Rt operator! () const β€” Return a new valarray by applying unary ! to each element.
  • template<class _Dom> valarray< _Tp > & operator%= (const _Expr< _Dom, _Tp > &) β€” no description given. she said "figure it out bestie." πŸ’…
  • valarray< _Tp > & operator%= (const _Tp &) β€” Set 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 > &) β€” no description. silent but deadly.
  • valarray< _Tp > & operator&= (const _Tp &) β€” Set 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 > &) β€” no description. mysterious as always.
  • 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 β€” Return a new valarray by applying unary + to each element.
  • template<class _Dom> valarray< _Tp > & operator+= (const _Expr< _Dom, _Tp > &) β€” no description, keeping it lowkey.
  • 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 β€” Return a new valarray by applying unary - to each element.
  • template<class _Dom> valarray< _Tp > & operator-= (const _Expr< _Dom, _Tp > &) β€” no description. πŸ™ˆ
  • valarray< _Tp > & operator-= (const _Tp &) β€” Subtract t to 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 > &) β€” no description. she's giving nothing and everything.
  • 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 > &) β€” no description. iykyk.
  • 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 > &) β€” no description.
  • 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 > &) β€” no description.
  • 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 description. she just is. πŸ’…
  • const _Tp & operator[] (size_t) const noexcept β€” also no description. the const girlies get it.
  • 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 > &) β€” no description.
  • 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 > &) β€” no description.
  • 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 β€” Return a new valarray by applying unary ~ to each element.
  • void resize (size_t __size, _Tp __c=_Tp()) β€” Resize array.
  • 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. that's it. that's the whole description. slay. ✨

πŸ‘‘ Friends πŸ‘‘

  • struct _Array< _Tp > β€” yeah she has friends. of course she does. she's popular. 🫢

🌈 Detailed Description 🌈

template<class _Tp>
class std::valarray< _Tp >

Smart array designed to support numeric processing.

okay so here's the tea. πŸ“

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.

translation bestie: she's a one-dimensional queen πŸ‘‘ who is also the gateway to every multidimensional subset you could ever want to access or modify. the constraints are there on purpose so the compiler can optimize her numeric processing without all that pointer-aliasing mess. it's giving "structured for your own good."

πŸ’« Template Parameters πŸ’«

  • _Tp β€” Type of object in the array.

like, what is she made of. that's _Tp. pick your poison. 🧚


πŸŽ€ 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.

References valarray().

ngl the way this one just hands you the first n elements and calls it a day... efficient. iconic. no further comment. πŸ’œ

more coming, bestie β€” stay tuned πŸ¦‹

✨ Member Function Documentation ✨

okay bestie, this is the part where valarray really shows out. πŸ’… every arithmetic operator you already know and love? it's here. every bitwise one? here too. and the compound-assign versions all mutate the array in place and hand you back a reference so you can chain them like it's nothing. each one does its thing to every element, element by element, no skipping, no cap.

let's go, one at a time 🫢


operator!

template<class _Tp> _UnaryOp< __logical_not >::_Rt std::valarray< _Tp >::operator! () const

returns a whole new valarray by slapping unary ! onto each element. iconique. ✨

operator%=

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator%= (const _Tp & )

sets each element e of the array to e % t. modulo time πŸ“

References valarray().

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator%= (const valarray< _Tp > & )

takes the modulo of the array's elements by the corresponding elements of v. matching energy, element for element πŸ’œ

References valarray().

operator&=

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator&= (const _Tp & )

sets each element e of the array to e & t. bitwise besties ✨

References valarray().

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator&= (const valarray< _Tp > & )

logical and of the corresponding elements of v with the elements of the array. they're matching each other, it's giving chemistry 😭

References valarray().

operator*=

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator*= (const _Tp & )

multiplies each element of the array by t. glow up for every single one πŸ”₯

References valarray().

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator*= (const valarray< _Tp > & )

multiplies the elements of the array by the corresponding elements of v. pair them up, periodt πŸ’…

References valarray().

operator+

template<class _Tp> _UnaryOp< __unary_plus >::_Rt std::valarray< _Tp >::operator+ () const

returns a fresh new valarray by applying unary + to each element. yes, it's just vibes, but it's const vibes ✨

operator+=

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator+= (const _Tp & )

adds t to each element of the array. plus one for everyone πŸŽ€

References valarray().

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator+= (const valarray< _Tp > & )

adds the corresponding elements of v to the elements of the array. hand in hand fr fr 🫢

References valarray().

operator-

template<class _Tp> _UnaryOp< __negate >::_Rt std::valarray< _Tp >::operator- () const

returns a new valarray by applying unary - to each element. the ~negation~ era πŸ’€

operator-=

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator-= (const _Tp & )

subtracts t to each element of the array. (yes bestie, that's how the original says it, and I am not the one who's gonna argue with the docs πŸ’…)

References valarray().

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator-= (const valarray< _Tp > & )

subtracts the corresponding elements of v from the elements of the array. one array gives, the other takes 🌸

References valarray().

operator/=

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator/= (const _Tp & )

divides each element of the array by t. splitting the vibe evenly ✨

References valarray().

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator/= (const valarray< _Tp > & )

divides the elements of the array by the corresponding elements of v. match made in indexing heaven 😭

References valarray().

operator<<=

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator<<= (const _Tp & )

left shifts each element e of the array by t bits. scoot over, bit by bit 🌈

References valarray().

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator<<= (const valarray< _Tp > & )

left shifts the elements of the array by the corresponding elements of v. per-element shift counts, fancy πŸŽ€

operator>>=

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator>>= (const _Tp & )

right shifts each element e of the array by t bits. the other direction, equally iconic πŸ’œ

References valarray().

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator>>= (const valarray< _Tp > & )

right shifts the elements of the array by the corresponding elements of v. πŸ‘‘

References valarray().

operator^=

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator^= (const _Tp & )

sets each element e of the array to e ^ t. xor o'clock πŸ¦‹

References valarray().

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator^= (const valarray< _Tp > & )

logical xor of the corresponding elements of v with the elements of the array. either/or energy, never both πŸ’€

References valarray().

operator|=

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator|= (const _Tp & )

sets each element e of the array to e | t. ✨

template<class _Tp> valarray< _Tp > & std::valarray< _Tp >::operator|= (const valarray< _Tp > & )

logical or of the corresponding elements of v with the elements of the array. inclusive queen behavior 🌸

References valarray().

operator~

template<class _Tp> _UnaryOp< __bitwise_not >::_Rt std::valarray< _Tp >::operator~ () const

returns a brand-new valarray by applying unary ~ to each element. flip every bit, serve every look 🌈


πŸŽ€ Author πŸŽ€

generated automatically by Doxygen for libstdc++ from the source code. (not a human, just a very diligent little doc robot 🫢✨)


okay that's the whole page bestie, you made it to the end, and honestly? ate. πŸ‘‘

this came straight from the libstdc++ docs β€” page std::valarray< _Tp >(3), with whatever date stamp your build slapped on the footer πŸ’– no cap, that's the whole thing. go write some element-wise math and be iconic about it. periodt. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms