summaryrefslogtreecommitdiff
path: root/libstdc++-v3/doc/html/manual/support.html
blob: 39c8185c60dc23fb9dbd8a55fa81422f582c6357 (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Chapter 4.  Support</title><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"/><meta name="keywords" content="&#10;      ISO C++&#10;    , &#10;      library&#10;    "/><link rel="home" href="../spine.html" title="The GNU C++ Library"/><link rel="up" href="bk01pt02.html" title="Part II.  Standard Contents"/><link rel="prev" href="bk01pt02.html" title="Part II.  Standard Contents"/><link rel="next" href="dynamic_memory.html" title="Dynamic Memory"/></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 4. 
  Support
  
</th></tr><tr><td align="left"><a accesskey="p" href="bk01pt02.html">Prev</a> </td><th width="60%" align="center">Part II. 
    Standard Contents
  </th><td align="right"> <a accesskey="n" href="dynamic_memory.html">Next</a></td></tr></table><hr/></div><div class="chapter" title="Chapter 4.  Support"><div class="titlepage"><div><div><h2 class="title"><a id="std.support"/>Chapter 4. 
  Support
  <a id="id471617" class="indexterm"/>
</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl><dt><span class="section"><a href="support.html#std.support.types">Types</a></span></dt><dd><dl><dt><span class="section"><a href="support.html#std.support.types.fundamental">Fundamental Types</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.numeric_limits">Numeric Properties</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.null">NULL</a></span></dt></dl></dd><dt><span class="section"><a href="dynamic_memory.html">Dynamic Memory</a></span></dt><dt><span class="section"><a href="termination.html">Termination</a></span></dt><dd><dl><dt><span class="section"><a href="termination.html#support.termination.handlers">Termination Handlers</a></span></dt><dt><span class="section"><a href="termination.html#support.termination.verbose">Verbose Terminate Handler</a></span></dt></dl></dd></dl></div><p>
    This part deals with the functions called and objects created
    automatically during the course of a program's existence.
  </p><p>
    While we can't reproduce the contents of the Standard here (you
    need to get your own copy from your nation's member body; see our
    homepage for help), we can mention a couple of changes in what
    kind of support a C++ program gets from the Standard Library.
  </p><div class="section" title="Types"><div class="titlepage"><div><div><h2 class="title"><a id="std.support.types"/>Types</h2></div></div></div><div class="section" title="Fundamental Types"><div class="titlepage"><div><div><h3 class="title"><a id="std.support.types.fundamental"/>Fundamental Types</h3></div></div></div><p>
      C++ has the following builtin types:
    </p><div class="itemizedlist"><ul class="itemizedlist"><li class="listitem"><p>
	char
      </p></li><li class="listitem"><p>
	signed char
      </p></li><li class="listitem"><p>
	unsigned char
      </p></li><li class="listitem"><p>
	signed short
      </p></li><li class="listitem"><p>
	signed int
      </p></li><li class="listitem"><p>
	signed long
      </p></li><li class="listitem"><p>
	unsigned short
      </p></li><li class="listitem"><p>
	unsigned int
      </p></li><li class="listitem"><p>
	unsigned long
      </p></li><li class="listitem"><p>
	bool
      </p></li><li class="listitem"><p>
	wchar_t
      </p></li><li class="listitem"><p>
	float
      </p></li><li class="listitem"><p>
	double
      </p></li><li class="listitem"><p>
	long double
      </p></li></ul></div><p>
      These fundamental types are always available, without having to
      include a header file. These types are exactly the same in
      either C++ or in C.
    </p><p>
      Specializing parts of the library on these types is prohibited:
      instead, use a POD.
    </p></div><div class="section" title="Numeric Properties"><div class="titlepage"><div><div><h3 class="title"><a id="std.support.types.numeric_limits"/>Numeric Properties</h3></div></div></div><p>
    The header <code class="filename">limits</code> defines
    traits classes to give access to various implementation
    defined-aspects of the fundamental types. The traits classes --
    fourteen in total -- are all specializations of the template class
    <code class="classname">numeric_limits</code>, documented <a class="link" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00593.html">here</a>
    and defined as follows:
    </p><pre class="programlisting">
   template&lt;typename T&gt;
     struct class
     {
       static const bool is_specialized;
       static T max() throw();
       static T min() throw();

       static const int digits;
       static const int digits10;
       static const bool is_signed;
       static const bool is_integer;
       static const bool is_exact;
       static const int radix;
       static T epsilon() throw();
       static T round_error() throw();

       static const int min_exponent;
       static const int min_exponent10;
       static const int max_exponent;
       static const int max_exponent10;

       static const bool has_infinity;
       static const bool has_quiet_NaN;
       static const bool has_signaling_NaN;
       static const float_denorm_style has_denorm;
       static const bool has_denorm_loss;
       static T infinity() throw();
       static T quiet_NaN() throw();
       static T denorm_min() throw();

       static const bool is_iec559;
       static const bool is_bounded;
       static const bool is_modulo;

       static const bool traps;
       static const bool tinyness_before;
       static const float_round_style round_style;
     };
   </pre></div><div class="section" title="NULL"><div class="titlepage"><div><div><h3 class="title"><a id="std.support.types.null"/>NULL</h3></div></div></div><p>
     The only change that might affect people is the type of
     <code class="constant">NULL</code>: while it is required to be a macro,
     the definition of that macro is <span class="emphasis"><em>not</em></span> allowed
     to be <code class="constant">(void*)0</code>, which is often used in C.
    </p><p>
     For <span class="command"><strong>g++</strong></span>, <code class="constant">NULL</code> is
     <code class="code">#define</code>'d to be
     <code class="constant">__null</code>, a magic keyword extension of
     <span class="command"><strong>g++</strong></span>.
    </p><p>
     The biggest problem of #defining <code class="constant">NULL</code> to be
     something like <span class="quote"><span class="quote">0L</span></span> is that the compiler will view
     that as a long integer before it views it as a pointer, so
     overloading won't do what you expect. (This is why
     <span class="command"><strong>g++</strong></span> has a magic extension, so that
     <code class="constant">NULL</code> is always a pointer.)
    </p><p>In his book <a class="link" href="http://www.awprofessional.com/titles/0-201-92488-9/"><span class="emphasis"><em>Effective
    C++</em></span></a>, Scott Meyers points out that the best way
    to solve this problem is to not overload on pointer-vs-integer
    types to begin with.  He also offers a way to make your own magic
    <code class="constant">NULL</code> that will match pointers before it
    matches integers.
    </p><p>See
      <a class="link" href="http://www.awprofessional.com/titles/0-201-31015-5/">the
      Effective C++ CD example</a>
    </p></div></div></div><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td align="left"><a accesskey="p" href="bk01pt02.html">Prev</a> </td><td align="center"><a accesskey="u" href="bk01pt02.html">Up</a></td><td align="right"> <a accesskey="n" href="dynamic_memory.html">Next</a></td></tr><tr><td align="left" valign="top">Part II. 
    Standard Contents
   </td><td align="center"><a accesskey="h" href="../spine.html">Home</a></td><td align="right" valign="top"> Dynamic Memory</td></tr></table></div></body></html>