
Aaron, On Mon, Jul 2, 2012 at 1:05 PM, Nathan Crookston <nathan.crookston@gmail.com> wrote:
On Mon, Jul 2, 2012 at 12:51 PM, <Aaron_Wright@selinc.com> wrote: <snip code>
What do I need to do in the second test to get it to compile? Can I tell if_ that its return type is not void?
Sadly no -- this was a point of confusion for me too. The correct way to do this is with if_else
Sorry to reply twice. The advice is correct, but the link is wrong (I'm not sure where if_else is documented. . .). The following shows usage: #include <boost/function.hpp> #include <boost/spirit/home/phoenix.hpp> #include <iostream> namespace px = boost::phoenix; using px::arg_names::arg1; int main() { boost::function<std::string(bool)> f = px::if_else(arg1, "true", "false"); std::cout << f(true) << std::endl; std::cout << f(false) << std::endl; return 0; } HTH, Nate