Boost logo

Boost Users :

Subject: [Boost-users] [Phoenix] Simple if_ issue
From: Aaron_Wright_at_[hidden]
Date: 2012-07-02 14:51:59


I'm trying to do a simple if/else statement using boost::phoenix and I
seem to mis-understanding something.

namespace bp = boost::phoenix;
namespace bpa = bp::arg_names;

boost::function< std::string () > test1 =
   bp::val("true");

boost::function< std::string (bool) > test2 =
   bp::if_(bpa::arg1)
   [
      bp::val("true")
   ]
   .else_
   [
      bp::val("false")
   ];

The first one works, but the second one doesn't. I get an error about not
being able to convert void to std::string:

cannot convert parameter 1 from 'void' to 'const
std::basic_string<_Elem,_Traits,_Ax> &

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?

---
Aaron Wright

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net