Can lambda functions be templated?

前端 未结 11 2570
你的背包
你的背包 2020-11-28 01:44

In C++11, is there a way to template a lambda function? Or is it inherently too specific to be templated?

I understand that I can define a classic templated class/fu

11条回答
  •  一个人的身影
    2020-11-28 01:49

    There is a gcc extension which allows lambda templates:

    // create the widgets and set the label
    base::for_each(_widgets, [] 
                             (boost::fusion::pair& pair) -> void {
                                 pair.second = new Widget_T();
                                 pair.second->set_label_str(Key_T::label);
                              }
                  );
    

    where _widgets is a std::tuple< fusion::pair... >

提交回复
热议问题