Boost logo

Boost :

From: John Maddock (jm_at_[hidden])
Date: 2003-01-30 07:38:36


> The following version works on g++ for the same cases that the current
> is_base_and_derived works (i.e. excluding multiple bases, and
> private/protected inheritance), and gives an error in the cases it doesn't
> work, while it works completely on the compilers that supports this (such
as
> Comeau C++ and Intel C++ 6/7). In other words, it "degrades gracefully",
and
> breaks noisily, if the compiler doesn't support the extra cases. This is
> tested on Comeau 4.3, Intel C++ 6/7 and g++ 3.2.

Except it *doesn't work* !

The problem is that your static assertion don't test anything, changing to:

//typedef char TestA[is_base_and_derived<B, D>::result]; // Multiple bases
(error on g++)
typedef char TestB[is_base_and_derived<B1,D>::result ? 1 : -1];
//typedef char TestC[is_base_and_derived<B2,D>::result]; // Private base
(error on g++)
typedef char TestD[!is_base_and_derived<int,D>::result ? 1 : -1];
typedef char TestE[!is_base_and_derived<B, B>::result ? 1 : -1];
typedef char TestF[is_base_and_derived<B,DV>::result ? 1 : -1]; // Virtual
base

and both Borland and gcc 3.21 give errors on cases 2 and 6

John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/index.htm


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