
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Dean Michael Berris Sent: Thursday, October 19, 2006 2:09 AM To: boost@lists.boost.org Subject: Re: [boost] Runtime Dynamic Dispatch (boost-dispatch)
Hi Guys,
On 10/19/06, Sohail Somani <s.somani@fincad.com> wrote:
can it be used for multimethods ?
Doesn't seem like it. It uses a single value to dispatch so it's the same thing as single dispatch. Shouldn't be impossible to dispatch based on multiple values though.
I have an example use (in the accompanying tests) which uses a boost::tuple<> as the index type. If the aim was to use multiple values, you can create a tuple from it and use that as an index -- then couple it with a validation and routing strategy that allows you to validate and manipulate the index used for the dispatch.
If you need to call multiple methods, you can use the invoker interface to the dispatcher -- but still using single dispatch. You can even use Boost.Signals to register a set of methods and register it to the dispatcher on a single index.
Cool! Can it do Common Lisp-like dispatch where it calls one function if 0 <= x < 5 and another if 5 <= x < 10?