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.
Better taste! Less fat! Literally!
In 1999, SGI added concept checkers to their implementation of the STL: code which checked the template parameters of instantiated pieces of the STL, in order to insure that the parameters being used met the requirements of the standard. For example, the Standard requires that types passed as template parameters to vector be "Assignable" (which means what you think it means). The checking was done during compilation, and none of the code was executed at runtime.
Unfortunately, the size of the compiler files grew significantly as a result. The checking code itself was cumbersome. And bugs were found in it on more than one occasion.
The primary author of the checking code, Jeremy Siek, had already started work on a replcement implementation. The new code has been formally reviewed and accepted into the Boost libraries, and we are pleased to incorporate it into the GNU C++ library.
The new version imposes a much smaller space overhead on the generated object file. The checks are also cleaner and easier to read and understand.
Concept checking can be disabled when you build your code, for example, to save space during a production build. Just define (via -D or #define) any of the macros _GLIBCPP_NO_CONCEPT_CHECKS (yes, with the leading underscore), _STL_NO_CONCEPT_CHECKS (also with the leading underscore), or NDEBUG. The first macro is specifically for this feature, the second is the disabling macro for the replaced SGI version (some code may assume SGI's version is in use), and the third is the usual macro to disable assert(), which is often turned off for production builds.
Return to top of page or to the FAQ.
Comments and suggestions are welcome, and may be sent to
the mailing list.
$Id: howto.html,v 1.2 2001/03/25 00:01:56 pme Exp $