aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/docs/html/19_diagnostics/howto.html
blob: bc6de3071ff6db23cef9a4f7411eac5632d4d0a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="AUTHOR" CONTENT="pme@sources.redhat.com (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">
<!-- $Id: howto.html,v 1.1.4.1 2001/05/14 19:48:55 bkoz Exp $ -->
</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&amp; 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>The <A HREF="exceptions_hiearchy.pdf">diagram</A> is in PDF, or
      at least it will be once it gets finished.
   </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
      <TT>vector</TT> be &quot;Assignable&quot; (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>.
<BR> $Id: howto.html,v 1.1.4.1 2001/05/14 19:48:55 bkoz Exp $
</EM></P>


</BODY>
</HTML>