Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-01-30 06:33:04


>From: "Andrei Alexandrescu" <andrewalex_at_[hidden]>

Sorry for the multiple posts.

> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
>
> > While we're at it, is the final verdict that is_base_and_derived<void,
X>
> > should be false? What about is_base_and_derived<void, void>?
>
> Well, clearly void is no base.

True.

> Even if we also define is_super_and_subtype,
> void is hardly a supertype of everything.

Well, it could be. It's like an "abstract base class", even for built-in
types - everything can be implicitly converted to void, or pointer to void,
and you can't instantiate a void. It's like Object in other languages, like
Java or Smalltalk - the supertype of everything. Also, substituting an
object where a void is expected, or a non-void pointer where a void pointer
is expected, still retains the original semantics. Thus, it obeys LSP.

This is something that could be detectable by is_convertible, anyway, had it
not been for the fact that it uses a specialisation for void to stop it.
Does anyone know why?

The docs says (save for the fact that, as has been pointed out earlier in
this thread, "object of type ..." could be better than "type") :

is_convertible<T,U>::value - Evaluates to true if type T is convertible to
type U.

In fact, if is_super_and_subtype is to obey LSP, would it be any different
from is_convertible?

Regards,

Terje


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