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_Exprconstructor 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 withnelements initialized totβ¨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 firstnelements oftβ pointer girlie behavior πΈvalarray (const gslice_array< _Tp > &)β constructs an array with the same size and values ingaπvalarray (const indirect_array< _Tp > &)β constructs an array with the same size and values iniaπ¦valarray (const mask_array< _Tp > &)β constructs an array with the same size and values inmaπvalarray (const slice_array< _Tp > &)β constructs an array with the same size and values insaπvalarray (const valarray &)β copy constructor. Copy-paste but make it classy πvalarray (initializer_list< _Tp >)β constructs an array with aninitializer_listof values πvalarray (size_t)β constructs an array withnelements β¨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 takesconst _Tp &πvalarray< _Tp > cshift (int __n) constβ returns a rotated array β circular shift slay π_Tp max () constβ returns the maximum element usingoperator<()π_Tp min () constβ returns the minimum element usingoperator<()π₯Ί_UnaryOp< __logical_not >::_Rt operator! () constβ returns a newvalarrayby applying unary!to each element πtemplate<class _Dom > valarray< _Tp > & operator%= (const _Expr< _Dom, _Tp > &)β the_Exproverload for%=; no extra description in the manual, but it's still invited πvalarray< _Tp > & operator%= (const _Tp &)β sets each elementeofarraytoe % tβ¨valarray< _Tp > & operator%= (const valarray< _Tp > &)β modulo elements ofarrayby corresponding elements ofvπ’template<class _Dom > valarray< _Tp > & operator&= (const _Expr< _Dom, _Tp > &)β the_Exproverload for&=; manual leaves this one description-less, we respect the mystery π«Άvalarray< _Tp > & operator&= (const _Tp &)β sets each elementeofarraytoe & tβ¨valarray< _Tp > & operator&= (const valarray< _Tp > &)β logical and corresponding elements ofvwith elements ofarrayπtemplate<class _Dom > valarray< _Tp > & operator*= (const _Expr< _Dom, _Tp > &)β the_Exproverload for*=; no extra blurb in the original, but it's on the roster πvalarray< _Tp > & operator*= (const _Tp &)β multiply each element ofarraybytβοΈvalarray< _Tp > & operator*= (const valarray< _Tp > &)β multiply elements ofarrayby corresponding elements ofvπ₯_UnaryOp< __unary_plus >::_Rt operator+ () constβ returns a newvalarrayby applying unary+to each element β¨template<class _Dom > valarray< _Tp > & operator+= (const _Expr< _Dom, _Tp > &)β the_Exproverload for+=; no extra description, still iconic πvalarray< _Tp > & operator+= (const _Tp &)β addtto each element ofarrayβvalarray< _Tp > & operator+= (const valarray< _Tp > &)β add corresponding elements ofvto elements ofarrayπ«Ά_UnaryOp< __negate >::_Rt operator- () constβ returns a newvalarrayby applying unary-to each element πtemplate<class _Dom > valarray< _Tp > & operator-= (const _Expr< _Dom, _Tp > &)β the_Exproverload for-=; manual has no extra one-liner, but it's here π«Άvalarray< _Tp > & operator-= (const _Tp &)β subtracttfrom each element ofarrayβvalarray< _Tp > & operator-= (const valarray< _Tp > &)β subtract corresponding elements ofvfrom elements ofarrayπtemplate<class _Dom > valarray< _Tp > & operator/= (const _Expr< _Dom, _Tp > &)β the_Exproverload for/=; no extra description in the manual, but it's not getting left out πΈvalarray< _Tp > & operator/= (const _Tp &)β divide each element ofarraybytβvalarray< _Tp > & operator/= (const valarray< _Tp > &)β divide elements ofarrayby corresponding elements ofvπ’template<class _Dom > valarray< _Tp > & operator<<= (const _Expr< _Dom, _Tp > &)β the_Exproverload for<<=; manual leaves it description-less, we still love her πvalarray< _Tp > & operator<<= (const _Tp &)β left shift each elementeofarraybytbits β¬ οΈvalarray< _Tp > & operator<<= (const valarray< _Tp > &)β left shift elements ofarrayby corresponding elements ofvβ¨template<class _Dom > valarray< _Tp > & operator= (const _Expr< _Dom, _Tp > &)β the_Exprassignment 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 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 > &)β the_Exproverload for>>=; no extra description in the original, but she's here πvalarray< _Tp > & operator>>= (const _Tp &)β right shift each elementeofarraybytbits β‘οΈvalarray< _Tp > & operator>>= (const valarray< _Tp > &)β right shift elements ofarrayby 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 extra description in the manual, but it's thesize_treference access and it's here πconst _Tp & operator[] (size_t) const noexceptβ no extra description, constsize_taccess, 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_Exproverload for^=; no extra description in the manual, but it stays πvalarray< _Tp > & operator^= (const _Tp &)β set each elementeofarraytoe ^ tβ¨valarray< _Tp > & operator^= (const valarray< _Tp > &)β logical xor corresponding elements ofvwith elements ofarrayπ₯template<class _Dom > valarray< _Tp > & operator|= (const _Expr< _Dom, _Tp > &)β the_Exproverload for|=; manual gives no extra one-liner, still invited π«Άvalarray< _Tp > & operator|= (const _Tp &)β set each elementeofarraytoe | tβ¨valarray< _Tp > & operator|= (const valarray< _Tp > &)β logical or corresponding elements ofvwith elements ofarrayπ_UnaryOp< __bitwise_not >::_Rt operator~ () constβ returns a newvalarrayby applying unary~to each element πvoid resize (size_t __size, _Tp __c=_Tp())β resize array. The default for__cis_Tp()π«Άvalarray< _Tp > shift (int __n) constβ return a shifted array πΈsize_t size () constβ return the number of elements inarrayπ’_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 elementeof array toe % tπtemplate<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator%= (const valarray< _Tp > &)β modulo the elements of array by the corresponding elements ofv, literally matchy-matchy πtemplate<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator&= (const _Tp &)β set each elementeof array toe & tπΈtemplate<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator&= (const valarray< _Tp > &)β logical and the corresponding elements ofvwith the elements of array, no cap β¨template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator*= (const _Tp &)β multiply each element of array bytπ₯template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator*= (const valarray< _Tp > &)β multiply the elements of array by the corresponding elements ofvπ¦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 &)β addtto each element of array βtemplate<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator+= (const valarray< _Tp > &)β add the corresponding elements ofvto 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 &)β subtracttfrom each element of array πtemplate<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator-= (const valarray< _Tp > &)β subtract the corresponding elements ofvfrom the elements of array πtemplate<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator/= (const _Tp &)β divide each element of array bytπtemplate<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator/= (const valarray< _Tp > &)β divide the elements of array by the corresponding elements ofvπtemplate<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator<<= (const _Tp &)β left shift each elementeof array bytbits π§template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator<<= (const valarray< _Tp > &)β left shift the elements of array by the corresponding elements ofvβtemplate<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator>>= (const _Tp &)β right shift each elementeof array bytbits π«Άtemplate<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator>>= (const valarray< _Tp > &)β right shift the elements of array by the corresponding elements ofvπ¦template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator^= (const _Tp &)β set each elementeof array toe ^ tπ₯template<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator^= (const valarray< _Tp > &)β logical xor the corresponding elements ofvwith the elements of array πtemplate<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator|= (const _Tp &)β set each elementeof array toe | tπΈtemplate<class _Tp > valarray< _Tp > & std::valarray< _Tp >::operator|= (const valarray< _Tp > &)β logical or the corresponding elements ofvwith 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 (!,+,-,~) areconstand give you back a new valarray, while the compound-assignment ones (%=,&=,*=,+=,-=,/=,<<=,>>=,^=,|=) hand you back avalarray< _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
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms