Common mathematical functions | |||||||||||||||||||||||||||||||
Mathematical special functions(C++17) | |||||||||||||||||||||||||||||||
Mathematical constants(C++20) | |||||||||||||||||||||||||||||||
Basic linear algebra algorithms(C++26) | |||||||||||||||||||||||||||||||
Data-parallel types (SIMD)(C++26) | |||||||||||||||||||||||||||||||
Floating-point environment(C++11) | |||||||||||||||||||||||||||||||
Complex numbers | |||||||||||||||||||||||||||||||
Numeric array (valarray ) | |||||||||||||||||||||||||||||||
Pseudo-random number generation | |||||||||||||||||||||||||||||||
Bit manipulation(C++20) | |||||||||||||||||||||||||||||||
Saturation arithmetic(C++26) | |||||||||||||||||||||||||||||||
Factor operations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Interpolations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Generic numeric operations | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
C-style checked integer arithmetic | |||||||||||||||||||||||||||||||
|
Member functions | ||||||||||||||||
Non-member functions | ||||||||||||||||
| ||||||||||||||||
Helper classes | ||||||||||||||||
Deduction guides(C++17) |
Defined in header <valarray> | ||
template<class T> std::valarray<bool> operator==(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); | (1) | |
template<class T> std::valarray<bool> operator==(consttypenamestd::valarray<T>::value_type& lhsv, | (2) | |
template<class T> std::valarray<bool> operator==(conststd::valarray<T>& lhs, | (3) | |
Compares each value within the numeric array with another value.
The behavior is undefined ifsize()!= v.size().
Contents |
lhs, rhs | - | numeric arrays to compare |
lhsv, rhsv | - | values to compare to each element within a numeric array |
A numeric array ofbool containing comparison results of corresponding elements.
May throw implementation-defined exceptions.
Each of the operators can only be instantiated if the following requirements are met:
T
.The function can be implemented with the return type different fromstd::valarray. In this case, the replacement type has the following properties:
#include <iostream>#include <valarray> int main(){// zero all negatives in a valarraystd::valarray<int> v={1,-1,0,-3,10,-1,-2};std::cout<<"Before: ";for(auto n: v)std::cout<< n<<' ';std::cout<<'\n'; v[v<0]=0;std::cout<<"After: ";for(auto n: v)std::cout<< n<<' ';std::cout<<'\n'; // convert the valarray<bool> result of == to a single boolstd::valarray<int> a={1,2,3};std::valarray<int> b={2,4,6}; std::cout<<"2*a == b is "<<std::boolalpha<<(2* a== b).min()<<'\n';}
Output:
Before: 1 -1 0 -3 10 -1 -2After: 1 0 0 0 10 0 02*a == b is true
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 3074 | C++98 | T is deduced from both the scalar and thevalarray for(2,3),disallowing mixed-type calls | only deduceT from thevalarray |