| 1 |
// Copyright (C) 2020-2025 Free Software Foundation, Inc. |
| 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 |
|
| 18 |
// expensive: * [1-9] * * |
| 19 |
#include "bits/main.h" |
| 20 |
|
| 21 |
using schar = signed char; |
| 22 |
using uchar = unsigned char; |
| 23 |
using ushort = unsigned short; |
| 24 |
using uint = unsigned int; |
| 25 |
using ulong = unsigned long; |
| 26 |
using llong = long long; |
| 27 |
using ullong = unsigned long long; |
| 28 |
using ldouble = long double; |
| 29 |
using wchar = wchar_t; |
| 30 |
using char16 = char16_t; |
| 31 |
using char32 = char32_t; |
| 32 |
|
| 33 |
template <typename M0, typename M1> |
| 34 |
constexpr bool |
| 35 |
bit_and_is_illformed() |
| 36 |
{ |
| 37 |
return is_substitution_failure<M0, M1, std::bit_and<>>; |
| 38 |
} |
| 39 |
|
| 40 |
template <typename M0, typename M1> |
| 41 |
void |
| 42 |
test_binary_op_cvt() |
| 43 |
{ |
| 44 |
COMPARE((bit_and_is_illformed<M0, M1>()), !(std::is_same_v<M0, M1>) ); |
| 45 |
} |
| 46 |
|
| 47 |
template <typename V> |
| 48 |
void |
| 49 |
test() |
| 50 |
{ |
| 51 |
using M = typename V::mask_type; |
| 52 |
// binary ops without conversions work |
| 53 |
COMPARE(typeid(M() & M()), typeid(M)); |
| 54 |
|
| 55 |
// nothing else works: no implicit conv. or ambiguous |
| 56 |
using std::experimental::fixed_size_simd_mask; |
| 57 |
using std::experimental::native_simd_mask; |
| 58 |
using std::experimental::simd_mask; |
| 59 |
test_binary_op_cvt<M, bool>(); |
| 60 |
|
| 61 |
test_binary_op_cvt<M, simd_mask<ldouble>>(); |
| 62 |
test_binary_op_cvt<M, simd_mask<double>>(); |
| 63 |
test_binary_op_cvt<M, simd_mask<float>>(); |
| 64 |
test_binary_op_cvt<M, simd_mask<ullong>>(); |
| 65 |
test_binary_op_cvt<M, simd_mask<llong>>(); |
| 66 |
test_binary_op_cvt<M, simd_mask<ulong>>(); |
| 67 |
test_binary_op_cvt<M, simd_mask<long>>(); |
| 68 |
test_binary_op_cvt<M, simd_mask<uint>>(); |
| 69 |
test_binary_op_cvt<M, simd_mask<int>>(); |
| 70 |
test_binary_op_cvt<M, simd_mask<ushort>>(); |
| 71 |
test_binary_op_cvt<M, simd_mask<short>>(); |
| 72 |
test_binary_op_cvt<M, simd_mask<uchar>>(); |
| 73 |
test_binary_op_cvt<M, simd_mask<schar>>(); |
| 74 |
test_binary_op_cvt<M, simd_mask<wchar>>(); |
| 75 |
test_binary_op_cvt<M, simd_mask<char16>>(); |
| 76 |
test_binary_op_cvt<M, simd_mask<char32>>(); |
| 77 |
|
| 78 |
test_binary_op_cvt<M, native_simd_mask<ldouble>>(); |
| 79 |
test_binary_op_cvt<M, native_simd_mask<double>>(); |
| 80 |
test_binary_op_cvt<M, native_simd_mask<float>>(); |
| 81 |
test_binary_op_cvt<M, native_simd_mask<ullong>>(); |
| 82 |
test_binary_op_cvt<M, native_simd_mask<llong>>(); |
| 83 |
test_binary_op_cvt<M, native_simd_mask<ulong>>(); |
| 84 |
test_binary_op_cvt<M, native_simd_mask<long>>(); |
| 85 |
test_binary_op_cvt<M, native_simd_mask<uint>>(); |
| 86 |
test_binary_op_cvt<M, native_simd_mask<int>>(); |
| 87 |
test_binary_op_cvt<M, native_simd_mask<ushort>>(); |
| 88 |
test_binary_op_cvt<M, native_simd_mask<short>>(); |
| 89 |
test_binary_op_cvt<M, native_simd_mask<uchar>>(); |
| 90 |
test_binary_op_cvt<M, native_simd_mask<schar>>(); |
| 91 |
test_binary_op_cvt<M, native_simd_mask<wchar>>(); |
| 92 |
test_binary_op_cvt<M, native_simd_mask<char16>>(); |
| 93 |
test_binary_op_cvt<M, native_simd_mask<char32>>(); |
| 94 |
|
| 95 |
test_binary_op_cvt<M, fixed_size_simd_mask<ldouble, 2>>(); |
| 96 |
test_binary_op_cvt<M, fixed_size_simd_mask<double, 2>>(); |
| 97 |
test_binary_op_cvt<M, fixed_size_simd_mask<float, 2>>(); |
| 98 |
test_binary_op_cvt<M, fixed_size_simd_mask<ullong, 2>>(); |
| 99 |
test_binary_op_cvt<M, fixed_size_simd_mask<llong, 2>>(); |
| 100 |
test_binary_op_cvt<M, fixed_size_simd_mask<ulong, 2>>(); |
| 101 |
test_binary_op_cvt<M, fixed_size_simd_mask<long, 2>>(); |
| 102 |
test_binary_op_cvt<M, fixed_size_simd_mask<uint, 2>>(); |
| 103 |
test_binary_op_cvt<M, fixed_size_simd_mask<int, 2>>(); |
| 104 |
test_binary_op_cvt<M, fixed_size_simd_mask<ushort, 2>>(); |
| 105 |
test_binary_op_cvt<M, fixed_size_simd_mask<short, 2>>(); |
| 106 |
test_binary_op_cvt<M, fixed_size_simd_mask<uchar, 2>>(); |
| 107 |
test_binary_op_cvt<M, fixed_size_simd_mask<schar, 2>>(); |
| 108 |
test_binary_op_cvt<M, fixed_size_simd_mask<wchar, 2>>(); |
| 109 |
test_binary_op_cvt<M, fixed_size_simd_mask<char16, 2>>(); |
| 110 |
test_binary_op_cvt<M, fixed_size_simd_mask<char32, 2>>(); |
| 111 |
} |