Declaration

    template<class AType> class TPointerTo {
    public:
       AType*GetAlias() const{return fPointer;}
       BooleanIsValid() const{return GetAlias() != NIL;}
       voidValidate() const{if ( ! IsValid()) throw TInvalidSafePointer();}
       AType*operator->() const{Validate(); return GetAlias();}
       AType&operator*() const{return *(operator->());}
    
    protected:
       TPointerTo (AType* p = NIL) : fPointer (p) {}
       void operator= (AType* p) {fPointer = p;}
       ~TPointerTo() {} // It's not permitted to delete a TPointerTo<>*.
       AType* Orphan();
    
    private:
       AType *fPointer;
    };
    
    template<class AType> AType*
    CopyPointer (const TPointerTo<AType>& from)
       {return CopyPointer (from.GetAlias());}
    template<class AType> AType*
    CopyPointer (const TPointerTo<AType>& from, TMemoryHeap& into)
       {return CopyPointer (from.GetAlias(), into);}
    template<class AType> AType*
    CopyPointer (const TPointerTo<AType>& from, EHeapType t, const void* o)
       {return CopyPointer (from.GetAlias(), t, o);}
    
    template<class AType> void
    Flatten (const  TPointerTo<AType>& from, TStream& into)
       {Flatten (from.GetAlias(), into);}
    template<class AType> void
    StreamOutLengthAndFlatten (const  TPointerTo<AType>& from, TStream& into)
       {StreamOutLengthAndFlatten (from.GetAlias(), into);}
    

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker