1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
11 // <experimental/simd>
14 // reference operator++() && noexcept;
15 // value_type operator++(int) && noexcept;
16 // reference operator--() && noexcept;
17 // value_type operator--(int) && noexcept;
19 #include "../test_utils.h"
20 #include <experimental/simd>
22 namespace ex
= std::experimental::parallelism_v2
;
24 template <class T
, std::size_t>
25 struct CheckSimdReferenceUnaryOperators
{
26 template <class SimdAbi
>
27 void operator()() const {
28 ex::simd
<T
, SimdAbi
> origin_simd(static_cast<T
>(3));
29 static_assert(noexcept(++origin_simd
[0]));
30 assert(((T
)(++origin_simd
[0]) == static_cast<T
>(4)) && ((T
)origin_simd
[0] == static_cast<T
>(4)));
31 static_assert(noexcept(origin_simd
[0]++));
32 assert(((T
)(origin_simd
[0]++) == static_cast<T
>(4)) && ((T
)origin_simd
[0] == static_cast<T
>(5)));
33 static_assert(noexcept(--origin_simd
[0]));
34 assert(((T
)(--origin_simd
[0]) == static_cast<T
>(4)) && ((T
)origin_simd
[0] == static_cast<T
>(4)));
35 static_assert(noexcept(origin_simd
[0]--));
36 assert(((T
)(origin_simd
[0]--) == static_cast<T
>(4)) && ((T
)origin_simd
[0] == static_cast<T
>(3)));
40 int main(int, char**) {
41 test_all_simd_abi
<CheckSimdReferenceUnaryOperators
>();