Boost logo

Boost Users :

Subject: [Boost-users] [phoenix] lazy function to reference or const reference
From: alfC (alfredo.correa_at_[hidden])
Date: 2011-04-04 04:29:57


 Is it possible to use references as the type of the function wrapped
by lazy function. The reason I need this is because I need to
instatiate a lazy function inside a class and to a class while the
class does not have yet a complete definition. The application may
sound exotic but I see no intrinsic limitation why the following
doesn't work. If this is not possible because an intrinsic limitation
of phoenix, is there a workaround?

-- Thanks -- Alfredo

... is_odd_impl is defined as in
using namespace std;
using boost::phoenix::arg_names::arg1;
int main(){
        int cuatro = 4.;

        is_odd_impl ioi;
        clog << ioi(cuatro) << endl;

        boost::phoenix::function<is_odd_impl> fioi;
        clog << fioi(arg1)(cuatro) << endl;

        boost::phoenix::function<is_odd_impl&> fioi_ref(ioi);
        clog << fioi_ref(arg1)(cuatro) << endl; //doesn't compile !!!

        boost::phoenix::function<is_odd_impl const&> fioi_cref(ioi);
        clog << fioi_cref(arg1)(cuatro) << endl; //doesn't compile !!!

        return 0;

example error message:
error: invalid initialization of reference of type ‘const
is_odd_impl&’ from expression of type ‘const
boost::phoenix::default_domain_with_basic_expr, const is_odd_impl,
boost::proto::argsns_::term<boost::phoenix::detail::argument<1> >, 0l>
>, void, void, void, void, void, void, void, void, void, void>::type’

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at