Boost logo

Boost :

From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2004-01-08 04:40:29


Dan W. wrote:
> I've simplified the code, following from Daniel Wallin's comments,
>
> Version 1.01 -- Jan 8, 2004
> * Put this documentation in separate text file (was comments
> in invariants.hpp; and added use example below.
> * Got rid of enabled_ state, and first_call/last_call, and
> changed to using private inheritance of invariants class.
>
> I have NOT moved away from inheritance, however, as explained in
> invariants.txt under 'Rationale':
>
> ------------------------------
> It's been suggested to me that introducing inheritance and
> virtual functions via inheritance in debug mode might not be
> good ideas. Note however that,
> (A) as of version 1.01 there is no longer size augmentation
> via inheritance, since the only data member was removed.

Yes there is, there's still a virtual member function.

> (B) also as of version 1.01 private inheritance is used.
> (C) class invariants is templeted per derived, and therefore
> does not conduce to unwanted sibling relationships
> (D) the only virtual function inherited from invariants class
> is check_invariants(), which is pure virtual in the base,
> and no longer virtual in derived. This AFAIK should not
> cause the compiler to generate an otherwise absent virtual
> table.
> (E) Using inheritance allows one to use succint class member
> names in the invariant assertions, rather than have to
> dereference a pointer, or reference via '.'.

 From my implementation:

    struct my_type
    {
    private:
        friend class invariant_access;
        void invariant() const
        {
            ...
        }
    };

I don't see how it's related to inheritance. Or did you mean something
else?

-- 
Daniel Wallin

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