Boost logo

Boost Users :

From: Jaakko Jarvi (jarvi_at_[hidden])
Date: 2005-11-17 18:30:06


You would (if you already didn't) have to redefine
CALL_TEMPLATE_ARGS, CALL_FORMAL_ARGS, and
CALL_USE_ARGS macros too.

Then it (might) work. The lambda code-base will change significantly
with Phoenix-2, so I wouldn't invest
too much time on this. In the future there will be support for at
least 9 placeholders.

   Bets, Jaakko Järvi

On Nov 17, 2005, at 3:34 PM, Noel Belcourt wrote:

> HI,
>
> I'm trying to extend the number of placeholders in boost lambda
> 1.33.0.
> There are three available by default and I need at least one more
> (_4)
> .
>
> I've followed the pattern establish for _3 to define _4, modifying
> the
> following files along the way.
>
> // lambda/core.hpp
> boost::lambda::placeholder3_type free3 =
> boost::lambda::placeholder3_type();
> boost::lambda::placeholder4_type free4 =
> boost::lambda::placeholder4_type();
>
> boost::lambda::placeholder3_type& _3 = free3;
> boost::lambda::placeholder4_type& _4 = free4;
>
> // lambda/detail/lambda_functors.hpp
> template<> struct placeholder<FOURTH> {
> template<class SigArgs> struct sig {
> typedef typename detail::get_element_or_null_type<3,
> SigArgs>::type
> type;
> };
> template<class RET, CALL_TEMPLATE_ARGS>
> RET call(CALL_FORMAL_ARGS) const { CALL_USE_ARGS; return c; }
> };
>
> typedef const lambda_functor<placeholder<THIRD> > placeholder3_type;
> typedef const lambda_functor<placeholder<FOURTH> > placeholder4_type;
>
> // lambda/detail/arity_code.hpp
> enum { NONE = 0x00, // Notice we are using bits as flags here.
> FIRST = 0x01,
> SECOND = 0x02,
> THIRD = 0x04,
> FOURTH = 0x08,
> EXCEPTION = 0x10,
> RETHROW = 0x20};
>
> So now _4 is defined but I get compilation errors from
> boost/function/function_template.hpp when I attempt to use _4. Is
> there some change necessary to either lambda placeholders or to boost
> function to get it to work correctly?
>
> Thanks,
>
> -- Noel Belcourt
>
> // With the changes above, this code fails with the message below.
>
> #include <boost/function.hpp>
> #include <boost/lambda/bind.hpp>
>
> using namespace boost;
> using namespace boost::lambda;
>
> typedef function<void (int, int, double, double)> func_t;
>
> template <class T1, class T2, class T3, class T4>
> struct A {
> template <class R>
> A(void (R::*required)(T1, T2, T3, T4), R *r) : u(bind(required, r,
> _1, _2, _3, _4)) {}
> func_t u;
> };
>
> struct B {
> void f(int, int, double, double);
> };
>
> int main(int, char *[])
> {
> B b;
> A<int, int, double, double> a(&B::f, &b);
> return 0;
> }
>
>
> This is the error message from CW 9.6 on Darwin
>
> Error : call of non-function
> (point of instantiation: 'main(int, char **)')
> (instantiating: 'A<int, int, double, double>::A<B>(void (B::*)(int,
> double, double), B *)')
> (instantiating: 'boost::function4<void, int, int, double, double,
> std::allocator<void>>::function4 `base
> constructor'<boost::lambda::lambda_functor<boost::lambda::
> lambda_functor_base<boost::lambda::action<6,
> boost::lambda::function_action<6,
> boost::lambda::detail::unspecified>>,
> boost::tuples::tuple<void (B::*const )(int, double, double), B
> *const ,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<2>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<4>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<8>>,
> boost::tuples::null_type, boost::tuples::null_type,
> boost::tuples::null_type,
> boost::tuples::null_type>>>>(boost::lambda::lambda_functor<boost::
> lambda::lambda_functor_base<boost::lambda::action<6,
> boost::lambda::function_action<6,
> boost::lambda::detail::unspecified>>,
> boost::tuples::tuple<void (B::*const )(int, double, double), B
> *const ,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<2>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<4>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<8>>,
> boost::tuples::null_type, boost::tuples::null_type,
> boost::tuples::null_type, boost::tuples::null_type>>>, int)')
> (instantiating: 'boost::function4<void, int, int, double, double,
> std::allocator<void>>::assign_to<boost::lambda::lambda_functor<boost::
> lambda::lambda_functor_base<boost::lambda::action<6,
> boost::lambda::function_action<6,
> boost::lambda::detail::unspecified>>,
> boost::tuples::tuple<void (B::*const )(int, double, double), B
> *const ,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<2>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<4>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<8>>,
> boost::tuples::null_type, boost::tuples::null_type,
> boost::tuples::null_type,
> boost::tuples::null_type>>>>(boost::lambda::lambda_functor<boost::
> lambda::lambda_functor_base<boost::lambda::action<6,
> boost::lambda::function_action<6,
> boost::lambda::detail::unspecified>>,
> boost::tuples::tuple<void (B::*const )(int, double, double), B
> *const ,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<2>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<4>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<8>>,
> boost::tuples::null_type, boost::tuples::null_type,
> boost::tuples::null_type, boost::tuples::null_type>>>)')
> (instantiating: 'boost::function4<void, int, int, double,
> double,
> std::allocator<void>>::assign_to<boost::lambda::lambda_functor<boost::
> lambda::lambda_functor_base<boost::lambda::action<6,
> boost::lambda::function_action<6,
> boost::lambda::detail::unspecified>>,
> boost::tuples::tuple<void (B::*const )(int, double, double), B
> *const ,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<2>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<4>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<8>>,
> boost::tuples::null_type, boost::tuples::null_type,
> boost::tuples::null_type,
> boost::tuples::null_type>>>>(boost::lambda::lambda_functor<boost::
> lambda::lambda_functor_base<boost::lambda::action<6,
> boost::lambda::function_action<6,
> boost::lambda::detail::unspecified>>,
> boost::tuples::tuple<void (B::*const )(int, double, double), B
> *const ,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<1>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<2>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<4>>,
> const boost::lambda::lambda_functor<boost::lambda::placeholder<8>>,
> boost::tuples::null_type, boost::tuples::null_type,
> boost::tuples::null_type, boost::tuples::null_type>>>,
> boost::detail::function::function_obj_tag)')
> (instantiating:
> 'boost::detail::function::void_function_obj_invoker4<boost::lambda::
> lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::
> action<6, boost::lambda::function_action<6,
> boost::lambda::detail::unspecified>>, boost::tuples::tuple<void
> (B::*const )(int, double, double), B *const , const
> boost::lambda::lambda_functor<boost::lambda::placeholder<1>>, const
> boost::lambda::lambda_functor<boost::lambda::placeholder<2>>, const
> boost::lambda::lambda_functor<boost::lambda::placeholder<4>>, const
> boost::lambda::lambda_functor<boost::lambda::placeholder<8>>,
> boost::tuples::null_type, boost::tuples::null_type,
> boost::tuples::null_type, boost::tuples::null_type>>>, void, int, int,
> double, double>::invoke(boost::detail::function::any_pointer, int,
> int,
> double, double)')
> function_template.hpp line 136
> BOOST_FUNCTION_RETURN((*f)(BOOST_FUNCTION_ARGS));
>
> Error : call of non-function
> (instantiating:
> 'boost::detail::function::void_function_obj_invoker4<boost::lambda::
> lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::
> action<6, boost::lambda::function_action<6,
> boost::lambda::detail::unspecified>>, boost::tuples::tuple<void
> (B::*const )(int, double, double), B *const , const
> boost::lambda::lambda_functor<boost::lambda::placeholder<1>>, const
> boost::lambda::lambda_functor<boost::lambda::placeholder<2>>, const
> boost::lambda::lambda_functor<boost::lambda::placeholder<4>>, const
> boost::lambda::lambda_functor<boost::lambda::placeholder<8>>,
> boost::tuples::null_type, boost::tuples::null_type,
> boost::tuples::null_type, boost::tuples::null_type>>>, void, int, int,
> double, double>::invoke(boost::detail::function::any_pointer, int,
> int,
> double, double)')
> function_template.hpp line 136
> BOOST_FUNCTION_RETURN((*f)(BOOST_FUNCTION_ARGS));
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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