Код: Выделить всё
#include
#include
#include
#include
#include
#include
#include
template
struct iterable_sfinae
{
template
static auto check(U*u)->decltype(u->begin()!=u->end());
template
static void check(...);
static constexpr bool value = !std::is_void_v;
};
template
static constexpr bool is_iterable_v = iterable_sfinae::value;
template
concept Iterable = iterable_sfinae::value;
template
constexpr bool is_numeric_v = std::numeric_limits::is_specialized;
template
concept Number = std::numeric_limits::is_specialized;
// alternative 2
template
auto findmax(C const &c)
requires is_numeric_v
{
auto rv = std::numeric_limits::lowest();
for (auto e: c)
if (e > rv) rv = e;
return rv;
}
int main() {
std::vector v = {9, 255, 86, 4, 89, 6, 1, 422, 5, 29};
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/73587304/why-isnt-stdinitializer-list-being-deduced-as-an-argument-for-a-concept-that[/url]