Boost logo

Boost :

From: Rani Sharoni (rani_sharoni_at_[hidden])
Date: 2003-01-30 08:25:13


"Terje Slettebø" <tslettebo_at_[hidden]> wrote in message
news:05e001c2c7b8$ebb14b50$cb6c6f50_at_pc...
>
> template<typename B, typename D>
> struct helper
> {
> template<typename T>
> static char check(D const volatile &, T);
> static char (& check(B const volatile &, int))[2];
>
> struct C
> {
> operator B const volatile &() const;
> operator D const volatile &();
> };
>
> static C getC();
> };
>
> template<typename B, typename D>
> struct is_base_and_derived
> {
> static const bool result =
> sizeof(helper<B,D>::check(helper<B,D>::getC(), 0)) == 1;
> };
>
> // If strict interpretation, i.e. not its own base class
>
> template<typename T>
> struct is_base_and_derived<T, T>
> {
> static const bool result = false;
> };
>

Ironically this specialization has the same behavior as the primary
template.

Rani


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