Обновить
0

Пользователь

Отправить сообщение
на 17 можно как-то так
template <typename R, typename ... Types> 
constexpr std::integral_constant<unsigned, sizeof ...(Types)> argument_cout( R(*f)(Types ...))
{
   return std::integral_constant<unsigned, sizeof ...(Types)>{};
}

auto curry = [](auto func, auto ... args)
{
	constexpr auto size_carry = sizeof...(args);
	if constexpr (size_carry == decltype(argument_cout(func))::value)
		return func(args...);
    else
	return [=](auto ... xs)
	{
		if constexpr (sizeof...(xs) + size_carry == decltype(argument_cout(func))::value)
			return func(args..., xs...);
		else
			return curry(func, args..., xs...);
	};
};

int value(int i, int f, int g)
{
    return i+f+g;
}

int main() {

std::cout << curry(value,1,2,3) << std::endl;
auto v1 = curry(value);
auto v2 = v1(1);
auto v3 = v2(2);
auto v4 = v3(3);
std::cout << curry(value)(1,2)(3) + v4 << std::endl;
return 0;
}

Информация

В рейтинге
Не участвует
Зарегистрирован
Активность