2000-04-21 20:33:34 +00:00
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
|
|
|
<HTML>
|
|
|
|
<HEAD>
|
|
|
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
2000-07-11 21:45:08 +00:00
|
|
|
<META NAME="AUTHOR" CONTENT="pme@sources.redhat.com (Phil Edwards)">
|
configopts.html, [...]: Remove many EGCS references...
* docs/configopts.html, docs/install.html, docs/17_intro/BADNAMES,
docs/17_intro/howto.html, docs/18_support/howto.html,
docs/19_diagnostics/howto.html, docs/20_util/howto.html,
docs/21_strings/howto.html, docs/22_locale/howto.html,
docs/23_containers/howto.html, docs/24_iterators/howto.html,
docs/25_algorithms/howto.html, docs/26_numerics/howto.html,
docs/27_io/howto.html, docs/ext/howto.html, docs/faq/index.html:
Remove many EGCS references; use current absolute URLs on
gcc.gnu.org or sources.redhat.com for messages in list archives.
* docs/faq/index.txt: Regenerate.
From-SVN: r36988
2000-10-21 01:51:50 +01:00
|
|
|
<META NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL">
|
2000-04-21 20:33:34 +00:00
|
|
|
<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">
|
2001-09-15 00:41:11 +00:00
|
|
|
<!-- $Id: howto.html,v 1.4 2001/05/30 21:54:59 pme Exp $ -->
|
2000-04-21 20:33:34 +00:00
|
|
|
</HEAD>
|
|
|
|
<BODY>
|
|
|
|
|
|
|
|
<H1 CLASS="centered"><A NAME="top">Chapter 19: Diagnostics</A></H1>
|
|
|
|
|
|
|
|
<P>Chapter 19 deals with program diagnostics, such as exceptions
|
2000-07-07 21:13:28 +00:00
|
|
|
and assertions. You know, all the things we wish weren't even
|
|
|
|
necessary at all.
|
2000-04-21 20:33:34 +00:00
|
|
|
</P>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ####################################################### -->
|
|
|
|
<HR>
|
|
|
|
<H1>Contents</H1>
|
|
|
|
<UL>
|
|
|
|
<LI><A HREF="#1">Adding data to exceptions</A>
|
|
|
|
<LI><A HREF="#2">Exception class hierarchy diagram</A>
|
2001-04-03 00:26:58 +00:00
|
|
|
<LI><A HREF="#3">Concept checkers -- <STRONG>new and improved!</STRONG></A>
|
2000-04-21 20:33:34 +00:00
|
|
|
</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:
|
2001-03-25 00:01:57 +00:00
|
|
|
My_Exception (const string& whatarg)
|
2000-04-21 20:33:34 +00:00
|
|
|
: 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>
|
2001-09-15 00:41:11 +00:00
|
|
|
<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>.
|
2000-04-21 20:33:34 +00:00
|
|
|
</P>
|
|
|
|
<P>Return <A HREF="#top">to top of page</A> or
|
|
|
|
<A HREF="../faq/index.html">to the FAQ</A>.
|
|
|
|
</P>
|
|
|
|
|
2000-07-07 21:13:28 +00:00
|
|
|
<HR>
|
2001-04-03 00:26:58 +00:00
|
|
|
<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
|
|
|
|
<TT>vector</TT> be "Assignable" (which means what you think
|
|
|
|
it means). The checking was done during compilation, and none of
|
|
|
|
the code was executed at runtime.
|
2000-07-07 21:13:28 +00:00
|
|
|
</P>
|
2001-04-03 00:26:58 +00:00
|
|
|
<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.
|
2000-07-07 21:13:28 +00:00
|
|
|
</P>
|
2001-04-03 00:26:58 +00:00
|
|
|
<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.
|
2001-03-25 00:01:57 +00:00
|
|
|
</P>
|
2001-04-03 00:26:58 +00:00
|
|
|
<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.
|
2001-03-25 00:01:57 +00:00
|
|
|
</P>
|
2001-05-30 21:55:05 +00:00
|
|
|
<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.
|
2001-03-25 00:01:57 +00:00
|
|
|
</P>
|
2001-04-03 00:26:58 +00:00
|
|
|
|
2000-07-07 21:13:28 +00:00
|
|
|
<P>Return <A HREF="#top">to top of page</A> or
|
|
|
|
<A HREF="../faq/index.html">to the FAQ</A>.
|
|
|
|
</P>
|
|
|
|
|
|
|
|
|
2000-04-21 20:33:34 +00:00
|
|
|
<!-- ####################################################### -->
|
|
|
|
|
|
|
|
<HR>
|
|
|
|
<P CLASS="fineprint"><EM>
|
|
|
|
Comments and suggestions are welcome, and may be sent to
|
2001-04-03 00:26:58 +00:00
|
|
|
<A HREF="mailto:libstdc++@gcc.gnu.org">the mailing list</A>.
|
2001-09-15 00:41:11 +00:00
|
|
|
<BR> $Id: howto.html,v 1.4 2001/05/30 21:54:59 pme Exp $
|
2000-04-21 20:33:34 +00:00
|
|
|
</EM></P>
|
|
|
|
|
|
|
|
|
|
|
|
</BODY>
|
|
|
|
</HTML>
|