From: Marco Costalba (mcostalba_at_[hidden])
Date: 2007-09-30 11:12:19
On 9/30/07, Dean Michael Berris <mikhailberis_at_[hidden]> wrote:
> > is not clear to me when and where this invokers are called given that
> > dispatcher::operator returns a function object reference. Or perhaps
> > I misread.
> Can you refer to which page in the documentation you see that?
If you mean the above example is in:
> The invoker is intended to be used this way:
Thanks, now it's much more clear.
> The immediate "top of my head" implementation would be to do a linear
> inheritance of the different Functor objects that support different
> signatures to represent a multi-signature Functor wrappers.
--------- cut ---------------
> void foo(double d) ;
> void bar(string s) ;
> void fizz(int i) ;
> multi_index_dispatcher d;
> d = foo; // valid, will register the void(double)
> d = bar; // valid, will register the void(string)
> d = fizz; // valid, will register the void(int)
Also Dispatcher::operator=() should be 'stacked' in some way though...but how?
> d(1.0); // valid, will call the void(double)
> d(1); // valid, will call the void(int)
> d("1"); // valid, will call the void(string)
> This might also be achievable with an encapsulated Fusion map instead
> of linear inheritance, but I'm not entirely sure about being able to
> generate the appropriate type-safe operator() overloads in that
Perhaps if the key of the map is the function signature could be
possible first find a match with the supplied arguments and then call
the operator(), should be safe in that case. A (big) downside is that
you forget implicit conversions this way.
> Thank you for the interest, and I definitely hope the above
> explanation helps. :)
Helped a lot.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk