operator== (<valarray>)
Tests whether the corresponding elements of two equally sized valarrays are equal or whether all the elements of a valarray are equal a specified value.
template<class Type>
valarray<bool> operator==(
const valarray<Type>& _Left,
const valarray<Type>& _Right
);
template<class Type>
valarray<bool> operator==(
const valarray<Type>& _Left,
const Type& _Right
);
template<class Type>
valarray<bool> operator==(
const Type& _Left,
const valarray<Type>& _Right
);
Parameters
_Left
The first of the two valarrays whose elements are to be tested for equality._Right
The second of the two valarrays whose elements are to be tested for equality.
Return Value
A valarray of Boolean values, each of which is:
true if the corresponding elements are equal.
false if the corresponding elements are not equal.
Remarks
The first template operator returns an object of class valarray<bool>, each of whose elements I is _Left[I] == _Right[I]. The second template operator stores in element I _Left[I] == _Right. The third template operator stores in element I _Left == _Right[I].
Example
// valarray_op_eq.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>
int main( )
{
using namespace std;
int i;
valarray<int> vaL ( 10 ), vaR ( 10 );
valarray<bool> vaNE ( 10 );
for ( i = 0 ; i < 10 ; i += 2 )
vaL [ i ] = -i;
for ( i = 1 ; i < 10 ; i += 2 )
vaL [ i ] = i;
for ( i = 0 ; i < 10 ; i++ )
vaR [ i ] = i;
cout << "The initial Left valarray is: ( ";
for (i = 0 ; i < 10 ; i++ )
cout << vaL [ i ] << " ";
cout << ")." << endl;
cout << "The initial Right valarray is: ( ";
for ( i = 0 ; i < 10 ; i++ )
cout << vaR [ i ] << " ";
cout << ")." << endl;
vaNE = ( vaL == vaR );
cout << "The element-by-element result of "
<< "the equality comparison test is the\n valarray: ( ";
for ( i = 0 ; i < 10 ; i++ )
cout << vaNE [ i ] << " ";
cout << ")." << endl;
}
The initial Left valarray is: ( 0 1 -2 3 -4 5 -6 7 -8 9 ). The initial Right valarray is: ( 0 1 2 3 4 5 6 7 8 9 ). The element-by-element result of the equality comparison test is the valarray: ( 1 1 0 1 0 1 0 1 0 1 ).
Requirements
Header: <valarray>
Namespace: std