]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/experimental/simd/tests/generator.cc
1 // Copyright (C) 2020 Free Software Foundation, Inc.
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)
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.
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/>.
18 #include "bits/verify.h"
19 #include "bits/metahelpers.h"
26 operator()(const F
& f
) -> decltype(V(f
));
29 using schar
= signed char;
30 using uchar
= unsigned char;
31 using ullong
= unsigned long long;
37 using T
= typename
V::value_type
;
38 V
x([](int) { return T(1); });
40 // unconditionally returns int from generator lambda
41 x
= V([](int) { return 1; });
43 x
= V([](auto i
) { return T(i
); });
44 COMPARE(x
, V([](T i
) { return i
; }));
46 VERIFY((// that int always works
47 sfinae_is_callable
<int (&)(int)>(call_generator
<V
>())));
48 COMPARE(sfinae_is_callable
<schar (&)(int)>(call_generator
<V
>()),
49 std::is_signed
<T
>::value
);
50 COMPARE(sfinae_is_callable
<uchar (&)(int)>(call_generator
<V
>()),
51 !(std::is_signed_v
<T
> && sizeof(T
) <= sizeof(uchar
)));
52 COMPARE(sfinae_is_callable
<float (&)(int)>(call_generator
<V
>()),
53 (std::is_floating_point
<T
>::value
));
55 COMPARE(sfinae_is_callable
<ullong (&)(int)>(call_generator
<V
>()),
56 std::__finite_max_v
<T
> >= std::__finite_max_v
<ullong
>
57 && std::__digits_v
<T
> >= std::__digits_v
<ullong
>);