Boost logo

Boost Users :

Subject: Re: [Boost-users] [RFC] Signals bound to phoenix functions
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2010-06-24 04:33:40


Stephan,

as I stated before in the [] you need to have a function object which is
called when the if_-condition is evaluated. It should not be a function
call, returning a non-function object!
Replacing Line 148 with:

return n_signal.connect( if_( CallingBack ) [m_signal_callback]);

will compile. If you need more complex szenario you need to make a composite
function object, which calls both functions. Anything in [] should return a
function object.

I suggest you first try to create a sample composite function object without
the whole complex machinery around and try to compile and run it first. Then
you can take the function object over into your sample.

Hope that helps,
Ovanes

On Thu, Jun 24, 2010 at 9:11 AM, Stephan Menzel <stephan.menzel_at_[hidden]>wrote:

> Ovanes,
>
> you are right in as much as there's something wrong with what's inside
> the if. Problem is, I've tried far more than just what I posted here
> and I couldn't get it to compile once. So I figured I may use if_ the
> wrong way.
>
> Anyway, not posting a standalone example is generally not a good idea
> but I wanted to focus more on the general idea and how to tackle it
> rather than what may be wrong with a particular code example I may or
> may not have. Anyway, I'll attach at least a standalone test of what I
> meant here.
>
> It shows the error nicely but contains lots of other crap I've played
> around with.
>
> Cheers,
> Stephan
>
>
>
>
>
> On Wed, Jun 23, 2010 at 6:50 PM, Ovanes Markarian
> <om_boost_at_[hidden]> wrote:
> > Stephan, hi!
> > please see my answer below.
> >
> > On Wed, Jun 23, 2010 at 5:42 PM, Stephan Menzel <
> stephan.menzel_at_[hidden]>
> > wrote:
> >>
> >> Unless I want to add something. Unfortunately I can't always take
> >> wrap()s output but have to modify a little. In fact, my Queue needs to
> >> be templatized as well, modifying the behaviour of the functor. I have
> >> a template parameter "Calling". When it is true, another function
> >> shall be called by the functor after the method was posted. Now I
> >> wanted to do this by phoenix:
> >>
> >> template <bool Calling>
> >> class Queue {
> >> template<typename Handler>
> >> void post(Handler n_handler) {
> >> m_iosrv.post(n_handler);
> >> };
> >> ...
> >> template<typename SlotSignature, typename SlotFunction>
> >> boost::signals2::connection
> >> connect(boost::signals2::signal<SlotSignature> &n_signal, SlotFunction
> >> n_method) {
> >> return n_signal.connect(
> >> if_( CallingBack ) [
> >> post(n_method) , m_signal_callback()
> >> ] .else_ [
> >> m_iosrv.wrap( n_method )
> >> ] );
> >> };
> >> ...
> >
> > It is difficult to conclude smth from the code without having a
> > self-containing example. But my assumption is that in the 'else'-branch
> your
> > code does not generate a function object. As far as I can see in the
> > 'if'-branch your code generates a function object using the the
> > comma-operator (if that operator is overloaded in Phoenix), in the
> > 'else'-branch you just have a normal function call, which is not lazy and
> > does not return a function-object.
> > Hope that helps,
> > Ovanes
> >
> >
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden]
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> >
>
> _______________________________________________
> 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