Re: [sigc] Generic member functors



Hello Klaus,

> There are no ambiguities with sigc++. There are templates involved, so
> you can't e.g. assign a mem_functor typed for a child to a mem_functor
> typed for a Parent. And I think you are mixing slots and functors...

I am sorry, you are apparently right.


> A slot represents a callable entity, no matter what functor is behind.
> So, a slot is the generic functor you want to have (only knowing about
> the return type and parameters, but loosing compile-time information
> about the original functor).

Thank you very much for explaining this to me. It is precisely what I need.

> What you want to do is the following:

> <code>
> Parent p;
> Child c;

> sigc::slot<int, Parent*, int, double, char> myclosure;

> myclosure = sigc::mem_fun(&Parent::f);
> const int ret1 = myclosure(&p, 0, 1.0, 'c');

> myclosure = sigc::mem_fun(&Child::g); <-- Error line
> const int ret2 = myclosure(&c, 0, 1.0, 'c');
> </code>


> Klaus Triend

Does this code compile for you? I just did copy and paste and tried to compile the above code. The result was:

error: invalid conversion from ‘Parent* const’ to ‘Child*’

This is the same error I described before in the attached file.

So, if this is the right way to cope with my problem, why it refuses to compile?



But anyway, thank you for a brief and valuable response.
Now I at leas understand better what is what ...


See all the ways you can stay connected to friends and family


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]