// Copyright (C) 2020-2024 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . // expensive: * [1-9] * * #include "bits/main.h" template struct call_generator { template auto operator()(const F& f) -> decltype(V(f)); }; using schar = signed char; using uchar = unsigned char; using ullong = unsigned long long; template void test() { using T = typename V::value_type; V x([](int) { return T(1); }); COMPARE(x, V(1)); // unconditionally returns int from generator lambda x = V([](int) { return 1; }); COMPARE(x, V(1)); x = V([](auto i) { return T(i); }); COMPARE(x, V([](T i) { return i; })); VERIFY((// that int always works sfinae_is_callable(call_generator()))); COMPARE(sfinae_is_callable(call_generator()), std::is_signed::value); COMPARE(sfinae_is_callable(call_generator()), !(std::is_signed_v && sizeof(T) <= sizeof(uchar))); COMPARE(sfinae_is_callable(call_generator()), (std::is_floating_point::value)); COMPARE(sfinae_is_callable(call_generator()), std::__finite_max_v >= std::__finite_max_v && std::__digits_v >= std::__digits_v); }