#ifndef _CREF_H_ #define _CREF_H_ #include class NullPointerException {}; /** * Class that wraps a constant reference variable. * Useful for return value from a container find method. */ template class Cref { public: Cref( ) : obj( NULL ) { } explicit Cref( const Object & x ) : obj( &x ) { } const Object & get( ) const { if( isNull( ) ) throw NullPointerException( ); else return *obj; } bool isNull( ) const { return obj == NULL; } private: const Object *obj; }; #endif