カリー化
/*
2019-04-03 @d4isk_
*/
#include
template
auto funcADD(T x){
const char* msg = "HOGE ";
return [=](T y){
std::cout << msg << x << " " << y << std::endl;
return x + y;
};
}
int main()
{
{
auto&& retFunc = funcADD(1.1);
auto ret = retFunc(2.2);
std::cout << ret << std::endl;
ret = retFunc(3.3); // result 4.4
std::cout << ret << std::endl;
}
{
auto ret = funcADD(1)(3);
std::cout << ret << std::endl;
}
}
コメント