GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::mask_array(3) C++ Standard Libary std::mask_array(3)

std::mask_array - std::mask_array


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 provides access to the
subset of the valarray consisting of the elements whose indices correspond to true
values in the std::valarray<bool> mask.


Type Definition
value_type T


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>>=

// Run this code


#include <iostream>
#include <valarray>


int main()
{
std::valarray<int> data = {0,1,2,3,4,5,6,7,8,9};


std::cout << "Initial valarray: ";
for(int n: data) std::cout << n << ' ';
std::cout << '\n';


data[data > 5] = -1;
// the type of data>5 is std::valarray<bool>
// the type of data[data>5] is std::mask_array<int>


std::cout << "After v[v>5]=-1: ";
for(int n: data) std::cout << n << ' ';
std::cout << '\n';
}


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

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.