std::valarray<T>::operator= (3) - Linux Manuals
std::valarray<T>::operator=: std::valarray<T>::operator=
NAME
std::valarray<T>::operator= - std::valarray<T>::operator=
Synopsis
valarray<T>& operator=( const valarray<T>& other ); (1)
valarray<T>& operator=( valarray<T>&& other ) noexcept; (2) (since C++11)
valarray<T>& operator=( const T& val ); (3)
valarray<T>& operator=( const std::slice_array<T>& other); (4)
valarray<T>& operator=( const std::gslice_array<T>& other); (5)
valarray<T>& operator=( const std::mask_array<T>& other ); (6)
valarray<T>& operator=( const std::indirect_array<T>& other ); (7)
valarray<T>& operator=( std::initializer_list<T> il ); (8) (since C++11)
Replaces the contents of the numeric array.
1) Copy assignment operator. Each element of *this is assigned the value of the corresponding element of other. If the length of other does not equal the length of *this,
the behavior is undefined
(until C++11)
first resizes as if by resize(other.size())
(since C++11).
2) Move assignment operator. Replaces the contents of *this with those of other. The value of other is unspecified after this operation. The complexity of this operation may be linear if T has non-trivial destructors, but is usually constant otherwise.
3) Replaces each value in *this with a copy of val.
4-7) Replaces the contents of *this with the result of a generalized subscripting operation. The behavior is undefined if the length of the argument does not equal the length of *this or if any value on the left depends on the value on the right (e.g v=v[v>2]).
8) Assigns the contents of initializer list il. Equivalent to *this = valarray(il).
Parameters
other - another numeric array (or a mask) to assign
val - the value to initialize each element with
il - initializer list to assign
Return value
*this
Exceptions
1) (none)
3-8) (none)
Example
// Run this code
Output: