|
Boost Users : |
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-03-29 12:55:21
On Fri, Mar 28, 2008 at 7:26 PM, Steven Watanabe <watanabesj_at_[hidden]>
wrote:
> AMDG
>
> Robert Dailey wrote:
> > The problem is that the type of the packet is not known until runtime.
> > This makes it very difficult to make things "type safe" at compile
> > time. What Steven has presented is about as type-safe as you can make
> > it. However, the system does not prevent you from mismatching ID's
> > with actual packet types, but that's just a natural problem with data
> > driven designs.
> You could put the ID in the base Packet type. That should minimize the
> chances of mismatch.
Right now I'm already putting the ID as a static constant variable in each
derived type. I don't see a way to set the ID in the base Packet class,
since that would more than likely require CRTP or something. From what I
have seen the Packet base class cannot be a template. I suppose you could do
this if you used 3 levels of inheritance, but that seems ugly.
> original type of the packet, since what is being passed in (the ID) is
> > not known at compile time, as I've already stated.
> > Right now there is no possible way to have a factory that returns the
> It seems like a problem in multiple dispatching, which C++ just doesn't
> support very well natively.
>
> In Christ,
> Steven Watanabe
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