File: inheritance.yo

package info (click to toggle)
c%2B%2B-annotations 8.2.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 11,804 kB
  • ctags: 2,845
  • sloc: cpp: 15,418; makefile: 2,473; ansic: 165; perl: 90; sh: 29
file content (23 lines) | stat: -rw-r--r-- 1,250 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Now that tt(Conversion) has been defined it's easy to determine whether a type
tt(Base) is a (public) base class of a type tt(Derived).

Inheritance is determined a class teminspecting convertability of (const)
pointers. tt(Derived const *) can be converted to tt(Base const *) if
    itemization(
    it() both types are identical;
    it() tt(Base) is a public and unambiguous base class of tt(Derived);
    it() and (usually not intended) if tt(Base) is void.
    )
    Assuming the last conversion isn't used inheritance can be determined
using the following trait class tt(LBaseRDerived). tt(LBaseRDerived) provides
an enum tt(yes) which is 1 if the left type is a base class of the right type
and both types are different:
    verbinsert(LBASERDERIVED)(advancedtemplates/examples/conversion.h)

    If code should not consider a class to be its own base class, then the
trait class tt(LBaseRtrulyDerived) can be used to perform a  strict test. This
trait class adds a test for type-equality:
    verbinsert(LBASERTRUE)(advancedtemplates/examples/conversion.h)
    Example: the next statement displays tt(1: 0, 2: 1, 3: 0, 4: 1, 5: 0)
when executed from a tt(main) function:
    verbinsert(INHERITANCE)(advancedtemplates/examples/conversion.cc)