Boost logo

Boost Users :

Subject: Re: [Boost-users] [RFC] Signals bound to phoenix functions
From: Stephan Menzel (stephan.menzel_at_[hidden])
Date: 2010-06-24 03:11:51


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 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