---
name: "std::mask_array"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::mask_array/3cxx"
---

# std::mask\_array(3cxx)

Reference to selected subset of an array.

## NAME

std::mask\_array\< \_Tp \> - Reference to selected subset of an array.

## SYNOPSIS

`#include <valarray>`

### Public Types

**typedef** \_Tp **value\_type**\

### Public Member Functions

**mask\_array** (const **mask\_array** &)\
 Copy constructor. Both slices refer to the same underlying array.  template\<**class** **\_Dom** \> **void** **operator%=** (const \_Expr\< **\_Dom**, \_Tp \> &) const\
 **void** **operator%=** (const **valarray**\< \_Tp \> &) const\
 Modulo slice elements by corresponding elements of *v*.  template\<**class** **\_Dom** \> **void** **operator&=** (const \_Expr\< **\_Dom**, \_Tp \> &) const\
 **void** **operator&=** (const **valarray**\< \_Tp \> &) const\
 Logical and slice elements with corresponding elements of *v*.  template\<**class** **\_Dom** \> **void** **operator\*=** (const \_Expr\< **\_Dom**, \_Tp \> &) const\
 **void** **operator\*=** (const **valarray**\< \_Tp \> &) const\
 Multiply slice elements by corresponding elements of *v*.  template\<**class** **\_Dom** \> **void** **operator+=** (const \_Expr\< **\_Dom**, \_Tp \> &) const\
 **void** **operator+=** (const **valarray**\< \_Tp \> &) const\
 Add corresponding elements of *v* to slice elements.  template\<**class** **\_Dom** \> **void** **operator-=** (const \_Expr\< **\_Dom**, \_Tp \> &) const\
 **void** **operator-=** (const **valarray**\< \_Tp \> &) const\
 Subtract corresponding elements of *v* from slice elements.  template\<**class** **\_Dom** \> **void** **operator/=** (const \_Expr\< **\_Dom**, \_Tp \> &) const\
 **void** **operator/=** (const **valarray**\< \_Tp \> &) const\
 Divide slice elements by corresponding elements of *v*.  template\<**class** **\_Dom** \> **void** **operator\<\<=** (const \_Expr\< **\_Dom**, \_Tp \> &) const\
 **void** **operator\<\<=** (const **valarray**\< \_Tp \> &) const\
 Left shift slice elements by corresponding elements of *v*.  template\<**class** **\_Dom** \> **void** **operator=** (const \_Expr\< **\_Dom**, \_Tp \> &) const\
 template\<**class** **\_Ex** \> **void** **operator=** (const \_Expr\< **\_Ex**, \_Tp \> &\_\_e) const\
 **void** **operator=** (const \_Tp &) const\
 Assign all slice elements to *t*.  **mask\_array** & **operator=** (const **mask\_array** &)\
 Assignment operator. Assigns elements to corresponding elements of *a*.  template\<**typename** \_Tp \> **mask\_array**\< \_Tp \> & **operator=** (const **mask\_array**\< \_Tp \> &\_\_a)\
 **void** **operator=** (const **valarray**\< \_Tp \> &) const\
 template\<**class** **\_Dom** \> **void** **operator\>\>=** (const \_Expr\< **\_Dom**, \_Tp \> &) const\
 **void** **operator\>\>=** (const **valarray**\< \_Tp \> &) const\
 Right shift slice elements by corresponding elements of *v*.  template\<**class** **\_Dom** \> **void** **operator^=** (const \_Expr\< **\_Dom**, \_Tp \> &) const\
 **void** **operator^=** (const **valarray**\< \_Tp \> &) const\
 Logical xor slice elements with corresponding elements of *v*.  template\<**class** **\_Dom** \> **void** **operator\|=** (const \_Expr\< **\_Dom**, \_Tp \> &) const\
 **void** **operator\|=** (const **valarray**\< \_Tp \> &) const\
 Logical or slice elements with corresponding elements of *v*.

### Friends

**class** **valarray\< \_Tp \>**\

## Detailed Description

### template\<class \_Tp\>

class std::mask\_array\< \_Tp \>"Reference to selected subset of an array.

A mask\_array is a reference to the actual elements of an array specified by a bitmask in the form of an array of bool. The way to get a mask\_array is to call operator\[\](valarray\<bool\>) on a valarray. The returned mask\_array then permits carrying operations out on the referenced subset of elements in the original valarray.

For example, if a mask\_array is obtained using the array (false, true, false, true) as an argument, the mask array has two elements referring to array\[1\] and array\[3\] in the underlying array.

**Parameters**

*Tp* Element type.

## Constructor & Destructor Documentation

### template\<class \_Tp \> std::mask\_array\< \_Tp \>::mask\_array (const mask\_array\< \_Tp \> &)

Copy constructor. Both slices refer to the same underlying array.

## Member Function Documentation

### template\<class \_Tp \> void std::mask\_array\< \_Tp \>::operator%= (const valarray\< \_Tp \> &) const

Modulo slice elements by corresponding elements of *v*.

### template\<class \_Tp \> void std::mask\_array\< \_Tp \>::operator&= (const valarray\< \_Tp \> &) const

Logical and slice elements with corresponding elements of *v*.

### template\<class \_Tp \> void std::mask\_array\< \_Tp \>::operator\*= (const valarray\< \_Tp \> &) const

Multiply slice elements by corresponding elements of *v*.

### template\<class \_Tp \> void std::mask\_array\< \_Tp \>::operator+= (const valarray\< \_Tp \> &) const

Add corresponding elements of *v* to slice elements.

### template\<class \_Tp \> void std::mask\_array\< \_Tp \>::operator-= (const valarray\< \_Tp \> &) const

Subtract corresponding elements of *v* from slice elements.

### template\<class \_Tp \> void std::mask\_array\< \_Tp \>::operator/= (const valarray\< \_Tp \> &) const

Divide slice elements by corresponding elements of *v*.

### template\<class \_Tp \> void std::mask\_array\< \_Tp \>::operator\<\<= (const valarray\< \_Tp \> &) const

Left shift slice elements by corresponding elements of *v*.

### template\<class \_Tp \> mask\_array & std::mask\_array\< \_Tp \>::operator= (const mask\_array\< \_Tp \> &)

Assignment operator. Assigns elements to corresponding elements of *a*.

### template\<class \_Tp \> void std::mask\_array\< \_Tp \>::operator\>\>= (const valarray\< \_Tp \> &) const

Right shift slice elements by corresponding elements of *v*.

### template\<class \_Tp \> void std::mask\_array\< \_Tp \>::operator^= (const valarray\< \_Tp \> &) const

Logical xor slice elements with corresponding elements of *v*.

### template\<class \_Tp \> void std::mask\_array\< \_Tp \>::operator\|= (const valarray\< \_Tp \> &) const

Logical or slice elements with corresponding elements of *v*.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
