On Sat, Mar 29, 2008 at 12:08 PM, Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG

Robert Dailey wrote:
>
>     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.

I'm thinking of a non static member variable in the base class, which
can be set in
the constructor.

In Christ,
Steven Watanabe

Is there any reason why the ID needs to be available at runtime? Instead of your specialization, I do:

class WalkPacket : Packet
{
    static const PacketId ID = PID_WALKPACKET;
};

Is there any reason why this isn't sufficient?