FreeBSD Manual Pages
std::mask_array(3) C++ Standard Libary std::mask_array(3) NAME std::mask_array - std::mask_array Synopsis Defined in header <valarray> template< class T > class mask_array; std::mask_array is a helper template used by the valarray subscript operator with std::valarray<bool> argument. It has reference semantics and pro- vides access to the subset of the valarray consisting of the elements whose indices cor- respond to true values in the std::valarray<bool> mask. Member types Type Definition value_type T Member functions constructor constructs a mask_array (public member function) destructor destroys a mask_array (public member function) operator= assigns contents (public member function) operator+= operator-= operator*= operator/= operator%= performs arithmetic operation on the array referred by mask. operator&= (public member function) operator|= operator^= operator<<= operator>>= Example // Run this code #include <iostream> #include <valarray> void println(auto rem, const auto& data) { for (std::cout << rem; int n : data) std::cout << n << ' '; std::cout << '\n'; } int main() { std::valarray<int> data{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; println("Initial valarray: ", data); data[data > 5] = -1; // the type of data>5 is std::valarray<bool> // the type of data[data>5] is std::mask_array<int> println("After v[v>5]=-1: ", data); } Output: Initial valarray: 0 1 2 3 4 5 6 7 8 9 After v[v>5]=-1: 0 1 2 3 4 5 -1 -1 -1 -1 See also simd_mask data-parallel type with the element type bool (parallelism TS v2) (class template) http://cppreference.com 2024.06.10 std::mask_array(3)
NAME | Synopsis | Member types | Member functions | Example | Output: | See also
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::mask_array&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>
