Boost.Lambda - 解引用占位符 [英] Boost.Lambda - dereference placeholder
本文介绍了Boost.Lambda - 解引用占位符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法取消引用的lambda前pression?
Is there a way to dereference a placeholder inside lambda expression ?
boost::function<int(MyClass*)> f = _1->myMethod();
f(myObject);
我知道我可以做一个绑定:
I know I can make a binding:
boost::function<int(MyClass*)> f = boost::bind(&MyClass::myMethod, _1);
,但我想构建更复杂的前pression,if语句等。
, but I want to build more complex expression, with if statements and so on.
推荐答案
在理论上这应该工作:
struct Foo {
int bla() { return 2; }
};
boost::function<int(Foo*)> func = (_1 ->* &Foo::bla);
有href=\"http://lists.boost.org/boost-users/2006/11/23754.php\" rel=\"nofollow\">旧讨论,提供各种变通的提高邮件列表。所有这些似乎相当难看。我会坚持
嵌套结合
或得到一个现代的C ++编译器。
There is an old discussion featuring various work-arounds on the
Boost mailing list. All of them seem rather ugly. I'd stick
with nested bindS
or get a modern C++ compiler.
这篇关于Boost.Lambda - 解引用占位符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文