# std::experimental::simd_mask

> C++ Atlas: `cppatlas.com/w/cpp/experimental/simd/simd_mask` | Source: https://en.cppreference.com/w/cpp/experimental/simd/simd_mask | Domain: Technical specifications

The class template simd_mask is a data-parallel type with the element type bool. The width of a given simd_mask instantiation is a constant expression, determined by the template parameters.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <experimental/simd>

template< class T, class Abi = simd_abi::compatible<T> >
class simd_mask; // (parallelism TS v2)
```

The class template `simd_mask` is a data-parallel type with the element type `bool`. The width of a given `simd_mask` instantiation is a constant expression, determined by the template parameters. Specifically, `simd_mask<T, Abi>::size()` is always `simd<T, Abi>::size()`.

### Template parameters

- `T` - the element type `simd_mask` applies on
- `Abi` - the ABI type `simd_mask` applies on

### Helper alias templates

**Template — Definition**

- `template< class T, int N > using fixed_size_simd_mask`: `simd_mask<T, simd_abi::fixed_size<N>>`
- `template< class T > using native_simd_mask`: `simd_mask<T, simd_abi::native<T>>`

### Member types

**Member type — Definition**

- `value_type`: `bool`
- `reference`: implementation-defined
- `simd_type`: `simd<T, Abi>`
- `abi_type`: `Abi`

### Member functions

- (constructor) (parallelism TS v2): constructs a `simd_mask` object (public member function)
- `copy_from` (parallelism TS v2): loads `simd_mask` elements from contiguous memory (public member function)
- `copy_to` (parallelism TS v2): stores `simd_mask` elements to contiguous memory (public member function)
- `operator[]` (parallelism TS v2): accesses specified element (public member function)
- `operator!` (parallelism TS v2): negates each element (public member function)
- `size` [static] (parallelism TS v2): returns the width / number of elements (public static member function)

### Non-member functions

- `operator&&` (parallelism TS v2), `operator||`: element-wise logic operators (function)
- `operator&` (parallelism TS v2), `operator|`, `operator^`: element-wise bitwise operators (function)
- `operator&=` (parallelism TS v2), `operator|=`, `operator^=`: element-wise compound operators (function)
- `operator==` (parallelism TS v2), `operator!=`: element-wise relation operators (function)

### Example

> Note: This section is incomplete Reason: no example

### See also

- [`simd`](https://en.cppreference.com/w/cpp/experimental/simd/simd) (parallelism TS v2): data-parallel vector type (class template)
- [`mask_array`](https://en.cppreference.com/w/cpp/numeric/valarray/mask_array): proxy to a subset of a valarray after applying a boolean mask `operator[]` (class template)

---
Attribution: content from https://en.cppreference.com/w/cpp/experimental/simd/simd_mask (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.