// StatusValue.h #ifndef StatusValue_H #define StatusValue_H // Template to encapsualate a value and an integer status. // Typically used to return a value of the specified type // where an error is indicated with a nozero status. // #include template class StatusValue; // typdefs using the template typedef StatusValue StatusDouble; typedef StatusValue StatusInt; // class definition template class StatusValue { private: // attributes // status int _status; // value T _value; public: // methods // constructor StatusValue(int status,const T& value) : _status(status), _value(value) { }; // Destructor. ~StatusValue() { }; // Return the status. int status() const { return _status; }; // Return the status. int status() { return _status; }; // Return the value. const T& value() const { return _value; }; // Return the value. T& value() { return _value; }; }; template std::ostream& operator<<(std::ostream& stream, StatusValue sv); #endif #include "StatusValue.tpp"