8ddad08b9e
* include/Makefile.am: Remove RCS Id strings. * src/Makefile.am: Ditto. * docs/doxygen/run_doxygen: Ditto. * docs/html/configopts.html: Ditto. * docs/html/documentation.html: Ditto. * docs/html/explanations.html: Ditto. * docs/html/install.html: Ditto. * docs/html/17_intro/howto.html: Ditto. * docs/html/18_support/howto.html: Ditto. * docs/html/19_diagnostics/howto.html: Ditto. * docs/html/20_util/howto.html: Ditto. * docs/html/21_strings/howto.html: Ditto. * docs/html/22_locale/howto.html: Ditto. * docs/html/23_containers/howto.html: Ditto. * docs/html/24_iterators/howto.html: Ditto. * docs/html/25_algorithms/howto.html: Ditto. * docs/html/26_numerics/howto.html: Ditto. * docs/html/27_io/howto.html: Ditto. * docs/html/ext/howto.html: Ditto. * docs/html/ext/sgiexts.html: Ditto. * docs/html/faq/index.html: Ditto. * docs/html/faq/index.txt: Ditto. From-SVN: r45836
122 lines
4.5 KiB
HTML
122 lines
4.5 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
|
<html>
|
|
<head>
|
|
<meta HcodeP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
|
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)">
|
|
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL">
|
|
<meta NAME="DESCRIPTION" CONTENT="HOWTO for the libstdc++ chapter 19.">
|
|
<meta NAME="GENERATOR" CONTENT="vi and eight fingers">
|
|
<title>libstdc++-v3 HOWTO: Chapter 19</title>
|
|
<link REL=StyleSheet HREF="../lib3styles.css">
|
|
</head>
|
|
<body>
|
|
|
|
<h1 CLASS="centered"><a name="top">Chapter 19: Diagnostics</a></h1>
|
|
|
|
<p>Chapter 19 deals with program diagnostics, such as exceptions
|
|
and assertions. You know, all the things we wish weren't even
|
|
necessary at all.
|
|
</p>
|
|
|
|
|
|
<!-- ####################################################### -->
|
|
<hr>
|
|
<h1>Contents</h1>
|
|
<ul>
|
|
<li><a href="#1">Adding data to exceptions</a>
|
|
<li><a href="#2">Exception class hierarchy diagram</a>
|
|
<li><a href="#3">Concept checkers -- <strong>new and improved!</strong></a>
|
|
</ul>
|
|
|
|
<hr>
|
|
|
|
<!-- ####################################################### -->
|
|
|
|
<h2><a name="1">Adding data to exceptions</a></h2>
|
|
<p>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:
|
|
</p>
|
|
<PRE>
|
|
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
|
|
};
|
|
</PRE>
|
|
<p>Return <a href="#top">to top of page</a> or
|
|
<a href="../faq/index.html">to the FAQ</a>.
|
|
</p>
|
|
|
|
<hr>
|
|
<h2><a name="2">Exception class hierarchy diagram</a></h2>
|
|
<p>At one point we were going to make up a PDF of the exceptions
|
|
hierarchy, akin to the one done for the I/O class hierarchy.
|
|
Time was our enemy. Since then we've moved to Doxygen, which has
|
|
the useful property of not sucking. Specifically, when the source
|
|
code is changed, the diagrams are automatically brought up to date.
|
|
For the old way, we had to update the diagrams separately.
|
|
</p>
|
|
<p>There are several links to the Doxygen-generated pages from
|
|
<a href="../documentation.html">here</a>.
|
|
</p>
|
|
<p>Return <a href="#top">to top of page</a> or
|
|
<a href="../faq/index.html">to the FAQ</a>.
|
|
</p>
|
|
|
|
<hr>
|
|
<h2><a name="3">Concept checkers -- <strong>new and improved!</strong></a></h2>
|
|
<p>Better taste! Less fat! Literally!</p>
|
|
<p>In 1999, SGI added <em>concept checkers</em> 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
|
|
<code>vector</code> be "Assignable" (which means what you think
|
|
it means). The checking was done during compilation, and none of
|
|
the code was executed at runtime.
|
|
</p>
|
|
<p>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.
|
|
</p>
|
|
<p>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
|
|
<a href="http://www.boost.org/libs/concept_check/concept_check.htm">the
|
|
Boost libraries</a>, and we are pleased to incorporate it into the
|
|
GNU C++ library.
|
|
</p>
|
|
<p>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.
|
|
</p>
|
|
<p>Right now they are off by default. More will be added once
|
|
GCC 3.0 is released and we have time to revisit this topic.
|
|
</p>
|
|
|
|
<p>Return <a href="#top">to top of page</a> or
|
|
<a href="../faq/index.html">to the FAQ</a>.
|
|
</p>
|
|
|
|
|
|
<!-- ####################################################### -->
|
|
|
|
<hr>
|
|
<P CLASS="fineprint"><em>
|
|
Comments and suggestions are welcome, and may be sent to
|
|
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>.
|
|
</em></p>
|
|
|
|
|
|
</body>
|
|
</html>
|