Boost logo

Boost Users :

Subject: Re: [Boost-users] Auto dispatch metaprogramming tricks
From: Terry Golubiewski (tjgolubi_at_[hidden])
Date: 2010-05-21 11:35:44


I've attached a working (on Visual C++ 2008) example.
terry

----- Original Message -----
From: "Alexander Lamaison" <awl03_at_[hidden]>
Newsgroups: gmane.comp.lib.boost.user
To: <boost-users_at_[hidden]>
Sent: Friday, May 21, 2010 7:09 AM
Subject: Auto dispatch metaprogramming tricks

>I would like to dispatch messages to a class based simply on the *presence*
> of a message handler method.
>
> Currently, the classes maintain an MPL vector of the messages they handle
> and must implement a on(message<MESSAGE_ID>) method for each one. The
> dispatcher uses this compile-time list to build the dispatching code.
> This
> means the information is maintained twice and may fall out of sync (e.g.
> adding the handler but forgetting to update the message vector.
>
> Are there any template metaprogramming tricks I can employ to dispatch the
> message to a handler method if it exists and the default handler
> otherwise?
> All this information is available at compile time. The question is are
> templates are powerful enough to make use of it?
>
> Many thanks.
>
> Alex
>




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