Boost logo

Boost :

Subject: Re: [boost] [Interest] Value Dispatch
From: greened_at_[hidden]
Date: 2012-08-16 00:32:45


Larry Evans <cppljevans_at_[hidden]> writes:

> But the only reason why value dispatch does not have to deal with
> alignment is because the values are all empty. The only member
> values in vehicle is the tag:
>
> kind the_kind;
>
> As soon as you have to add other member variables (I assume a real
> Boat or a real Plane would have other member variables), you'll have to
> deal with alignment, if you want to save space.

I wrote value dispatch precisely for the case where one doesn't have to
save space. The particular project I'm using this for previously used
inheritance and virtual functions pretty much for the dispatch/compiler
generated switch stuff. They all share identical (template)
implementations and all had the same size.

Even so, nothing would prevent a plan ol' union in the classes, right?
You'll even be dispatched to a function that knows exactly which member
is the right one.

                           -Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk