Chapter 19 deals with program diagnostics, such as exceptions and assertions. You know, all the things we wish weren't even necessary at all.
The standard exception classes carry with them a single string as data (usually describing what went wrong or where the 'throw' took place). It's good to remember that you can add your own data to these exceptions when extending the heirarchy:
using std::runtime_error; struct My_Exception : public runtime_error { public: My_Exception (const string& whatarg) : runtime_error(whatarg), e(errno), id(GetDataBaseID()) { } int errno_at_time_of_throw() const { return e; } DBID id_of_thing_that_threw() const { return id; } protected: int e; DBID id; // some user-defined type };
Return to top of page or to the FAQ.
The diagram is in PDF, or at least it will be once it gets finished.
Return to top of page or to the FAQ.
As part of their 3.3 release, SGI added some nifty macros which perform assertions on type properties. For example, the Standard requires that types passed as template parameters to vector be "Assignable" (which means what you think it means).
The concept checkers allow the source code for vector to declare
__STL_CLASS_REQUIRES(_Tp, _Assignable);inside the template. _Tp is the element type of the vector, and _Assignable is the concept to be checked (it is defined in some back-end header files). When you instantiate vector<MyType>, compile-time checking can be done on whether MyType meets the requirements for vectors.
This is an extension to the library. This documentation needs updating.
Return to top of page or to the FAQ.
Comments and suggestions are welcome, and may be sent to
Phil Edwards or
Gabriel Dos Reis.
$Id: howto.html,v 1.2 2000/07/07 21:13:28 pme Exp $