Boost logo

Boost :

Subject: Re: [boost] xml?
From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2010-04-09 13:46:19

On 04/09/2010 12:46 PM, Stewart, Robert wrote:
> Stefan Seefeld wrote:
>> On 04/09/2010 12:34 PM, Larry Evans wrote:
>>> On 04/09/10 10:48, Mathias Gaunard wrote:
>>>> Some could argue that the point of a base class is moot if
>>>> you have to downcast it to make anything useful with it,
>>> But boost.variant has to do the equivalent of downcasting based on
>>> discriminant (the value returned by which()).
>> No, accessing a member of a union is not really a cast, neither
>> conceptually nor technically.
> Conceptually, they are doing the same: determining whether the requested type is appropriate and returning the appropriately typed value.

Right, but that's not the same as casting (in the sense of narrowing
down a more generic to a more specific type).
The difference is that in one case both types have a common ancestor /
super-type (implying a common interface of some form), while in the
other case they don't.

> However, dynamic_cast does so by comparing RTTI objects, which may be more expensive than the discriminator comparison, and then by apply fixups to the this pointer to account for MI, virtual bases, etc.
> What's more, once the dynamic_cast has been done, the various functions calls may still wind up being virtual, depending upon how things are implemented. When using Boost.Variant, the types used could have no virtual functions.

I'm not sure why you are saying all this. The point is really that there
is no common interface that integral / numerical types share with nodes
and node sets. Thus there is no sense in having these share some common
interface that would justify a common base class, making a union-like
accessor (such as boost.variant) the obvious accessor for XPath query
return values.


       ...ich hab' noch einen Koffer in Berlin...

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