什么是这个C++ 14结构被称为链接lambdas?

ste*_*anv 11 c++ lambda c++14

这是关于这一点的后续问题:C++ 14中的Lambda-Over-Lambda,答案解释了代码.

它是关于lambda创建另一个lambda,在调用时,调用传递的lambda并将返回值传递给原始lambda,从而返回第二个lambda的新实例.

该示例显示了lambdas可以链接的方式.

复制原始问题:

#include <cstdio>

auto terminal = [](auto term)            // <---------+  
{                                        //           |
    return [=] (auto func)               //           |  ???
    {                                    //           |
        return terminal(func(term));     // >---------+
    };
};


auto main() -> int
{
    auto hello =[](auto s){ fprintf(s,"Hello\n"); return s; };
    auto world =[](auto s){ fprintf(s,"World\n"); return s; };


    terminal(stdout)
            (hello)
            (world) ;

    return 0;

}
Run Code Online (Sandbox Code Playgroud)

是否已经有了这个结构的名称,如果不是,它应该被称为什么?它是否类似于其他语言的结构?

备注:我对它是否真的有用并不感兴趣.

Tob*_*obi 0

据我所知,目前还没有“正式”名称。

建议:

  • 拉姆达链
  • 拉姆达香肠
  • 咖喱香肠