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 withnelements initialized tot.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 firstnelements oft.valarray (const gslice_array< _Tp > &)β Construct an array with the same size and values inga.valarray (const indirect_array< _Tp > &)β Construct an array with the same size and values inia.valarray (const mask_array< _Tp > &)β Construct an array with the same size and values inma.valarray (const slice_array< _Tp > &)β Construct an array with the same size and values insa.valarray (const valarray &)β Copy constructor. making a whole new her, fr fr.valarray (initializer_list< _Tp >)β Construct an array with aninitializer_listof values.valarray (size_t)β Construct an array withnelements.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 usingoperator<()._Tp min () constβ Return the minimum element usingoperator<()._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 elementeof array toe % t.valarray< _Tp > & operator%= (const valarray< _Tp > &)β Modulo elements of array by corresponding elements ofv.template<class _Dom> valarray< _Tp > & operator&= (const _Expr< _Dom, _Tp > &)β no description. silent but deadly.valarray< _Tp > & operator&= (const _Tp &)β Set each elementeof array toe & t.valarray< _Tp > & operator&= (const valarray< _Tp > &)β Logical and corresponding elements ofvwith 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 byt.valarray< _Tp > & operator*= (const valarray< _Tp > &)β Multiply elements of array by corresponding elements ofv._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 &)β Addtto each element of array.valarray< _Tp > & operator+= (const valarray< _Tp > &)β Add corresponding elements ofvto 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 &)β Subtracttto each element of array.valarray< _Tp > & operator-= (const valarray< _Tp > &)β Subtract corresponding elements ofvfrom 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 byt.valarray< _Tp > & operator/= (const valarray< _Tp > &)β Divide elements of array by corresponding elements ofv.template<class _Dom> valarray< _Tp > & operator<<= (const _Expr< _Dom, _Tp > &)β no description. iykyk.valarray< _Tp > & operator<<= (const _Tp &)β Left shift each elementeof array bytbits.valarray< _Tp > & operator<<= (const valarray< _Tp > &)β Left shift elements of array by corresponding elements ofv.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 aninitializer_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 elementeof array bytbits.valarray< _Tp > & operator>>= (const valarray< _Tp > &)β Right shift elements of array by corresponding elements ofv.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 elementeof array toe ^ t.valarray< _Tp > & operator^= (const valarray< _Tp > &)β Logical xor corresponding elements ofvwith elements of array.template<class _Dom> valarray< _Tp > & operator|= (const _Expr< _Dom, _Tp > &)β no description.valarray< _Tp > & operator|= (const _Tp &)β Set each elementeof array toe | t.valarray< _Tp > & operator|= (const valarray< _Tp > &)β Logical or corresponding elements ofvwith 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