]>
Commit | Line | Data |
---|---|---|
83ffe9cd | 1 | // Copyright (C) 2020-2023 Free Software Foundation, Inc. |
02e32295 MK |
2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 3, or (at your option) | |
7 | // any later version. | |
8 | // | |
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | // | |
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
aa89c53c | 18 | // expensive: * [1-9] * * |
02e32295 MK |
19 | #include "bits/verify.h" |
20 | #include "bits/metahelpers.h" | |
21 | ||
22 | template <typename V> | |
23 | void | |
24 | test() | |
25 | { | |
26 | using M = typename V::mask_type; | |
27 | static_assert(std::is_convertible<typename M::reference, bool>::value, | |
28 | "A smart_reference<simd_mask> must be convertible to bool."); | |
29 | static_assert( | |
30 | std::is_same<bool, decltype(std::declval<const typename M::reference&>() | |
31 | == true)>::value, | |
32 | "A smart_reference<simd_mask> must be comparable against bool."); | |
33 | static_assert( | |
34 | vir::test::sfinae_is_callable<typename M::reference&&, bool>( | |
35 | [](auto&& a, auto&& b) -> decltype(std::declval<decltype(a)>() | |
36 | == std::declval<decltype(b)>()) { | |
37 | return {}; | |
38 | }), | |
39 | "A smart_reference<simd_mask> must be comparable against bool."); | |
40 | VERIFY(std::experimental::is_simd_mask_v<M>); | |
41 | ||
42 | { | |
43 | M x; // uninitialized | |
44 | x = M{}; // default broadcasts 0 | |
45 | COMPARE(x, M(false)); | |
46 | COMPARE(x, M()); | |
47 | COMPARE(x, M{}); | |
48 | x = M(); // default broadcasts 0 | |
49 | COMPARE(x, M(false)); | |
50 | COMPARE(x, M()); | |
51 | COMPARE(x, M{}); | |
52 | x = x; | |
53 | for (std::size_t i = 0; i < M::size(); ++i) | |
54 | { | |
55 | COMPARE(x[i], false); | |
56 | } | |
57 | } | |
58 | ||
59 | M x(true); | |
60 | M y(false); | |
61 | for (std::size_t i = 0; i < M::size(); ++i) | |
62 | { | |
63 | COMPARE(x[i], true); | |
64 | COMPARE(y[i], false); | |
65 | } | |
66 | y = M(true); | |
67 | COMPARE(x, y); | |
68 | } |