
Message: 11 Date: Thu, 19 Oct 2006 01:52:32 +0200 From: Janek Kozicki <janek_listy@wp.pl> Subject: Re: [boost] Runtime Dynamic Dispatch (boost-dispatch) To: boost@lists.boost.org Message-ID: <20061019015232.42b1ce98@absurd> Content-Type: text/plain; charset=US-ASCII Dean Michael Berris said: (by the date of Wed, 18 Oct 2006 22:24:09 +0800)
Hi Everyone,
I'm about to make a shameless plug about the runtime dispatch library I've been working on the past few months (mostly testing and using in a project), which I've uploaded to the vault: http://tinyurl.com/ycsq6n for everyone to check out and comment on.
can it be used for multimethods ?
Hi Michael, It looks like the rival for your library is not a switch statement or an if-else statement, but a hash_map. In your rationale, you should make clear what your library can do that the following construct cannot: template <typename T> struct dynamic_dispatcher { typedef hash_map< T, boost::function<void ()> > type; }; dynamic_dispatcher<int>::type dispatcher; dispatcher[0] = boost::bind(&myfun0); dispatcher[1] = boost::bind(&myfun1); int i; std::cin >> i; dispatcher[i]() From my reading, the only difference is that hash map's operator[] will not throw in the case where an element is not found. Best Regards, Matthew Herrmann Zomojo Pty Ltd