From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-02-03 08:04:44
From: "Gennaro Prota" <gennaro_prota_at_[hidden]>
> On Sat, 1 Feb 2003 20:01:15 -0800, "Eric Niebler" <neric_at_[hidden]>
> >"Gennaro Prota" <gennaro_prota_at_[hidden]> wrote
> >> Well, then I imagine you would prefer the old semantics. Was there
> >> anybody complaining that being not enough?
> >Yes, I was. A while back, I pointed out to Rani that is_base_and_derived
> >was insufficient to implement is_com_ptr, a trait I needed. In COM
> >programming, every interface inherits from IUnknown, and many COM objects
> >implement multiple interfaces. So is_base_and_derived<IUnknown,
> >MyCOMObject> was almost always ambiguous.
> >I was content to gripe, but Rani actually did something about it. The
> >behavior of is_base_and_derived is very welcome, IMO.
> Yes, Rani pointed out the usage for COM interfaces too, and that's a
> good one. I'm only a little perplexed about inaccessible bases,
> because the relevant example looks a little artificial; that doesn't
> mean that there aren't better examples, or that it is a good example
> but I have not understood it. As I said in another post, let's see how
> will this behave in practice. After all, boost is (also) a sort of
> test-bed for C++ libraries.
I think I have a use case for the new behavior.
When is_base_and_derived<B, D> says true, this means that every object of
type D has a subobject of type B. This can be used to determine the order of
if statements in the code below:
Modern C++ Design has an example of that.
The corrolaries are:
1. is_base_and_derived<X, X> must be false, or the predicate won't be
antireflexive and mpl::sort won't work.
2. mpl::sort must work with a partial ordering predicate.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk