简体   繁体   中英

Troubles with boost::phoenix::function

Using boost::phoenix::function I encountered some problems. As far as I know this lazy function requiries functor as its template parameter. I have to define a functor class/structure and then pass it as a template parameter for instantiation. But it's too long and redundant. Can I use some other callable type for phoenix::function creation (function reference/pointer etc.)? I tried lambdas :

 const auto foo = [] { cout <<"Test"; }
 const boost::phoenix::function<decltype(foo)> lazy;

but call to lazy() didn't compile. So the question are there any alternatives instead of functor classes for fast one-line phoenix::function creation?

由于foo的类型不是默认的可构造的, lazy需要初始化器:

boost::phoenix::function<decltype(foo)> lazy { foo };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM