1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14
10
11// <experimental/simd>
12//
13// [simd.class]
14// reference operator[](size_t i);
15// value_type operator[](size_t i) const;
16
17#include "../test_utils.h"
18#include <experimental/simd>
19
20namespace ex = std::experimental::parallelism_v2;
21
22template <class T, std::size_t>
23struct CheckSimdMaskReferenceSubscr {
24 template <class SimdAbi>
25 void operator()() {
26 ex::simd_mask<T, SimdAbi> origin_simd_mask(true);
27 for (size_t i = 0; i < origin_simd_mask.size(); ++i) {
28 static_assert(noexcept(origin_simd_mask[i]));
29 static_assert(std::is_same_v<typename ex::simd_mask<T, SimdAbi>::reference, decltype(origin_simd_mask[i])>);
30 assert(origin_simd_mask[i] == true);
31 }
32 }
33};
34
35template <class T, std::size_t>
36struct CheckSimdMaskValueTypeSubscr {
37 template <class SimdAbi>
38 void operator()() {
39 const ex::simd_mask<T, SimdAbi> origin_simd_mask(true);
40 for (size_t i = 0; i < origin_simd_mask.size(); ++i) {
41 static_assert(noexcept(origin_simd_mask[i]));
42 static_assert(std::is_same_v<bool, decltype(origin_simd_mask[i])>);
43 assert(origin_simd_mask[i] == true);
44 }
45 }
46};
47
48int main(int, char**) {
49 test_all_simd_abi<CheckSimdMaskReferenceSubscr>();
50 test_all_simd_abi<CheckSimdMaskValueTypeSubscr>();
51 return 0;
52}
53

source code of libcxx/test/std/experimental/simd/simd.mask.class/simd_mask_subscr.pass.cpp