带有模板参数的C ++ 0x lambda? [英] C++0x lambdas with template parameters?
问题描述
可能重复:
可以对lambda函数进行模板化吗?
Possible Duplicate:
Can lambda functions be templated?
是否可以使用带有模板参数的c ++ 0x lambda?例如:
Is it possible to have a c++0x lambda with template parameters? For example:
template <typename T> [=](const T *x) {}
我想做的是在类型列表(可变参数列表)上编写一个静态for循环,我想将当前类型作为参数传递给目标函子(或lambda)的运算符() ).
What I am trying to do is to code a static for loop on a type list (variadic argument list), and I want to pass the current type as a parameter to to the operator () of the target functor (or lambda).
推荐答案
That's called polymorphic lambda, I already asked about it there : Can lambda functions be templated?
不,这在C ++ 0x中是不可能的.也许是下一个.
And no it's not possible in C++0x. Maybe the next one.
但是 boost :: phoenix 允许这样做,所以这可能是一个不错的解决方法.
However boost::phoenix allows this so it might be a good workaround.
这篇关于带有模板参数的C ++ 0x lambda?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!