Boost logo

Boost :

Subject: Re: [boost] [Interest] Value Dispatch
From: Larry Evans (cppljevans_at_[hidden])
Date: 2012-08-15 23:00:18

On 08/15/12 20:34, greened_at_[hidden] wrote:
> [Note: I don't know why my e-mail address got mangled. It should be
> "greened_at_..."]
> Larry Evans <cppljevans_at_[hidden]> writes:
>> Could you not use boost::variant
> Thanks for your feedback!
> boost::variant can do some similar things but I think it is really aimed
> at a different problem. As I understand it, boost::variant's primary
> use case is to function as a type safe generalized union. Thus it has
> to deal with things like alignment, etc. that the presented technique
> (which I call "value dispatch" for lack of a better name) does not.

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.

> A
> quick glance at boost::variant source code shows that it is quite
> complex. IMHO, value dispatch is much simpler.



Boost list run by bdawes at, gregod at, cpdaniel at, john at