aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/docs/19_diagnostics/howto.html
blob: 3502ed3b8a4964f3048d5be8268159cd43a0411d (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
<!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.4 2000/10/21 00:51:49 jsm28 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</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>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</A></H2>
   <P>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 <TT>vector</TT>
      be &quot;Assignable&quot; (which means what you think it means).
   </P>
   <P>The concept checkers allow the source code for <TT>vector</TT> to
      declare
      <PRE>
   __STL_CLASS_REQUIRES(_Tp, _Assignable);
      </PRE>inside the template.  <TT>_Tp</TT> is the element type of the
      vector, and <TT>_Assignable</TT> is the concept to be checked (it is
      defined in some back-end header files).  When you instantiate
      <TT>vector&lt;MyType&gt;</TT>, compile-time checking can be done on
      whether MyType meets the requirements for vectors.
   </P>
<P>This is an extension to the library.  This documentation needs updating.</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:pme@sources.redhat.com">Phil Edwards</A> or
<A HREF="mailto:gdr@gcc.gnu.org">Gabriel Dos Reis</A>.
<BR> $Id: howto.html,v 1.4 2000/10/21 00:51:49 jsm28 Exp $
</EM></P>


</BODY>
</HTML>