-1- This clause describes the function signatures that are called implicitly, and the types of objects generated implicitly, during the execution of some C++ programs. It also describes the headers that declare these function signatures and define any related types.
-2- The following subclauses describe common type definitions used throughout the library, characteristics of the predefined types, functions supporting start and termination of a C++ program, support for dynamic memory management, support for dynamic type identification, support for exception processing, and other runtime support, as summarized in Table ??:
Subclause | Header(s) |
lib.support.types Types | <cstddef> |
lib.support.limits Implementation properties | <limits> |
<climits> | |
<cfloat> | |
lib.support.start.term Start and termination | <cstdlib> |
lib.support.dynamic Dynamic memory management | <new> |
lib.support.rtti Type identification | <typeinfo> |
lib.support.exception Exception handling | <exception> |
lib.support.runtime Other runtime support | <cstdarg> |
<csetjmp> | |
<ctime> | |
<csignal> | |
<cstdlib> |
18.1 - Types [lib.support.types]
-1- Common definitions.
-2- Header <cstddef> (Table ??):
Kind | Name(s) | |
Macros: | NULL | offsetof |
Types: | ptrdiff_t | size_t |
-3- The contents are the same as the Standard C library header <stddef.h>, with the following changes:
-4- The macro NULL is an implementation-defined C++ null pointer constant in this International Standard (conv.ptr).*
[Footnote: Possible definitions include 0 and 0L, but not (void*)0. --- end foonote]
-5- The macro offsetof accepts a restricted set of type arguments in this International Standard. type shall be a POD structure or a POD union (clause class). The result of applying the offsetof macro to a field that is a static data member or a function member is undefined.
See also
subclause expr.sizeof, Sizeof,
subclause expr.add, Additive operators,
subclause class.free, Free store, and
ISO C subclause 7.1.6.
18.2 - Implementation properties [lib.support.limits]
-1-
The headers
<limits>,
<climits>,
and
<cfloat>
supply characteristics of implementation-dependent fundamental types (basic.fundamental).
18.2.1 - Numeric limits [lib.limits]
-1- The numeric_limits component provides a C++ program with information about various properties of the implementation's representation of the fundamental types.
-2- Specializations shall be provided for each fundamental type, both floating point and integer, including bool. The member is_specialized shall be true for all such specializations of numeric_limits.
-3- For all members declared static const in the numeric_limits template, specializations shall define these values in such a way that they are usable as integral constant expressions.
-4- Non-fundamental standard types, such as complex<T> (lib.complex), shall not have specializations.
Header <limits> synopsis
namespace std { template<class T> class numeric_limits; enum float_round_style; enum float_denorm_style; template<> class numeric_limits<bool>; template<> class numeric_limits<char>; template<> class numeric_limits<signed char>; template<> class numeric_limits<unsigned char>; template<> class numeric_limits<wchar_t>; template<> class numeric_limits<short>; template<> class numeric_limits<int>; template<> class numeric_limits<long>; template<> class numeric_limits<unsigned short>; template<> class numeric_limits<unsigned int>; template<> class numeric_limits<unsigned long>; template<> class numeric_limits<float>; template<> class numeric_limits<double>; template<> class numeric_limits<long double>; }
namespace std { template<class T> class numeric_limits { public: static const bool is_specialized = false; static T min() throw(); static T max() throw();
static const int digits = 0; static const int digits10 = 0; static const bool is_signed = false; static const bool is_integer = false; static const bool is_exact = false; static const int radix = 0; static T epsilon() throw(); static T round_error() throw();
static const int min_exponent = 0; static const int min_exponent10 = 0; static const int max_exponent = 0; static const int max_exponent10 = 0; static const bool has_infinity = false; static const bool has_quiet_NaN = false; static const bool has_signaling_NaN = false; static const float_denorm_style has_denorm = denorm_absent; static const bool has_denorm_loss = false; static T infinity() throw(); static T quiet_NaN() throw(); static T signaling_NaN() throw(); static T denorm_min() throw(); static const bool is_iec559 = false; static const bool is_bounded = false; static const bool is_modulo = false; static const bool traps = false; static const bool tinyness_before = false; static const float_round_style round_style = round_toward_zero; }; }
-1- The member is_specialized makes it possible to distinguish between fundamental types, which have specializations, and non-scalar types, which do not.
-2-
The default
numeric_limits<T>
template shall have all members, but with 0 or
false
values.
18.2.1.2 - numeric_limits members [lib.numeric.limits.members]
static T min() throw();
-1- Minimum finite value.*
[Footnote: Equivalent to CHAR_MIN, SHRT_MIN, FLT_MIN, DBL_MIN, etc. --- end foonote]
-2- For floating types with denormalization, returns the minimum positive normalized value.
-3-
Meaningful for all specializations in which
is_bounded != false,
or
is_bounded == false && is_signed == false.
static T max() throw();
-4- Maximum finite value.*
[Footnote: Equivalent to CHAR_MAX, SHRT_MAX, FLT_MAX, DBL_MAX, etc. --- end foonote]
-5-
Meaningful for all specializations in which
is_bounded != false.
static const int digits;
-6- Number of radix digits that can be represented without change.
-7- For built-in integer types, the number of non-sign bits in the representation.
-8- For floating point types, the number of radix digits in the mantissa.*
[Footnote: Equivalent to FLT_MANT_DIG, DBL_MANT_DIG, LDBL_MANT_DIG. --- end foonote]
static const int digits10;
-9- Number of base 10 digits that can be represented without change.*
[Footnote: Equivalent to FLT_DIG, DBL_DIG, LDBL_DIG. --- end foonote]
-10-
Meaningful for all specializations in which
is_bounded != false.
static const bool is_signed;
-11- True if the type is signed.
-12-
Meaningful for all specializations.
static const bool is_integer;
-13- True if the type is integer.
-14-
Meaningful for all specializations.
static const bool is_exact;
-15- True if the type uses an exact representation. All integer types are exact, but not all exact types are integer. For example, rational and fixed-exponent representations are exact but not integer.
-16-
Meaningful for all specializations.
static const int radix;
-17- For floating types, specifies the base or radix of the exponent representation (often 2).*
[Footnote: Equivalent to FLT_RADIX. --- end foonote]
-18- For integer types, specifies the base of the representation.*
[Footnote: Distinguishes types with bases other than 2 (e.g. BCD). --- end foonote]
-19-
Meaningful for all specializations.
-1-
The rounding mode for floating point arithmetic is characterized by the
values:
-1-
The presence or absence of denormalization (variable number of exponent bits)
is characterized by the values:
-1-
All members shall be provided for all specializations.
However, many values are only required to be meaningful under certain
conditions
(for example,
epsilon()
is only meaningful if
is_integer
is
false).
Any value that is not ``meaningful'' shall be set to 0 or
false.
-2-
[Example:
-1-
Header
<climits>
(Table ??):
-2-
The contents are the same as the Standard C library header
<limits.h>.
-3-
Header
<cfloat>
(Table ??):
-4-
The contents are the same as the Standard C library header
<float.h>.
See also
ISO C subclause 7.1.5, 5.2.4.2.2, 5.2.4.2.1.
-1-
Header
<cstdlib>
(partial), Table ??:
-2-
The contents are the same as the Standard C library header
<stdlib.h>,
with the following changes:
-3-
The function
abort()
has additional behavior in this International Standard:
-4- Effects:
The
atexit()
functions register the function pointed to by f,
to be called without arguments at normal program termination.
-5-
For the execution of a function registered with
atexit(),
if control leaves the function because it provides no
handler for a thrown exception,
terminate()
is called (lib.terminate).
-6- Implementation Limits:
The implementation shall support the registration of at least 32 functions.
-7- Returns:
The
atexit()
function returns zero if the registration succeeds,
nozero if it fails.
-8-
The function
exit()
has additional behavior in this International Standard:
-9-
The function
exit()
never returns to its caller.
See also
subclauses basic.start, basic.start.term,
ISO C subclause 7.10.4.
-1-
The header
<new>
defines several
functions that manage the allocation of dynamic storage in a program.
It also defines components for reporting storage management errors.
Header <new> synopsis
See also
intro.memory, basic.stc.dynamic,
expr.new, expr.delete, class.free,
lib.memory.
-1- Effects:
The
allocation function
(basic.stc.dynamic.allocation)
called by a
new-expression
(expr.new)
to allocate
size bytes of storage suitably aligned to represent any object
of that size.
-2- Replaceable:
a C++ program may define a function with this function signature
that displaces the default version defined by the
C++ Standard library.
-3- Required behavior:
Return a non-null pointer to suitably aligned storage (basic.stc.dynamic),
or else throw a
bad_alloc
exception.
This requirement is binding on a replacement version of this function.
-4- Default behavior:
-5- Effects:
Same as above, except that it is called by a placement version of a
new-expression
when a C++ program prefers a null pointer result as an error indication,
instead of a
bad_alloc
exception.
-6- Replaceable:
a C++ program may define a function with this function signature
that displaces the default version defined by the
C++ Standard library.
-7- Required behavior:
Return a non-null pointer to suitably aligned storage (basic.stc.dynamic),
or else return a null pointer.
This nothrow version of
operator new
returns a pointer obtained as if acquired from the ordinary version.
This requirement is binding on a replacement version of this function.
-8- Default behavior:
-9-
[Example:
-10- Effects:
The
deallocation function
(basic.stc.dynamic.deallocation)
called by a
delete-expression
to render the value of ptr invalid.
-11- Replaceable:
a C++ program may define a function with this
function signature that displaces the default version defined by the
C++ Standard library.
-12- Required behavior:
accept a value of ptr that is null or that was returned by an
earlier call to the default
operator new(std::size_t)
or
operator new(std::size_t,const std::nothrow_t&).
-13- Default behavior:
-14- Notes:
It is unspecified under what conditions part or all of such
reclaimed storage is allocated by a subsequent call to
operator new
or any of
calloc,
malloc,
or
realloc,
declared in
<cstdlib>.
-1- Effects:
The
allocation function
(basic.stc.dynamic.allocation)
called by the array form of a
new-expression
(expr.new)
to allocate size bytes of storage suitably aligned to represent any array
object of that size or smaller.*
-2- Replaceable:
a C++ program can define a
function with this function signature that displaces the default version
defined by the C++ Standard library.
-3- Required behavior:
Same as for
operator new(std::size_t).
This requirement is binding on a replacement version of this function.
-4- Default behavior:
Returns
operator new( size ).
-5- Effects:
Same as above, except that it is called by a placement version of a
new-expression
when a C++ program prefers a null pointer result as an error indication,
instead of a
bad_alloc
exception.
-6- Replaceable:
a C++ program can define a
function with this function signature that displaces the default version
defined by the C++ Standard library.
-7- Required behavior:
Same as for
operator new(std::size_t,const std::nothrow_t&).
This nothrow version of
operator new[]
returns a pointer obtained as if acquired from the ordinary version.
-8- Default behavior:
Returns
operator new( size ,nothrow).
-9- Effects:
The
deallocation function
(basic.stc.dynamic.deallocation)
called by the array form of a
delete-expression
to render the value of ptr invalid.
-10- Replaceable:
a C++ program can define a function with this
function signature that displaces the default version defined by the
C++ Standard library.
-11- Required behavior:
accept a value of ptr that is null or that was returned
by an earlier call to
operator new[](std::size_t)
or
operator new[](std::size_t,const std::nothrow_t&).
-12- Default behavior:
-13-
It is unspecified under what conditions part or all of such reclaimed storage
is allocated by a subsequent call to
operator new
or any of
calloc,
malloc,
or
realloc,
declared in
<cstdlib>.
-1-
These functions are reserved, a C++ program may not define functions that displace
the versions in the Standard C++ library (lib.constraints).
-2- Returns:
ptr .
-3- Notes:
Intentionally performs no other action.
-4-
[Example:
This can be useful for constructing an object at a known address:
-5- Returns:
ptr .
-6- Notes:
Intentionally performs no other action.
-7- Effects:
Intentionally performs no action.
-8- Notes:
Default function called when any part of the initialization in a
placement new expression that invokes the library's
non-array placement operator new
terminates by throwing an exception (expr.new).
-9- Effects:
Intentionally performs no action.
-10- Notes:
Default function called when any part of the initialization in a
placement new expression that invokes the library's
array placement operator new
terminates by throwing an exception (expr.new).
-1-
The class
bad_alloc
defines the type of objects thrown as
exceptions by the implementation to report a failure to allocate storage.
-2- Effects:
Constructs an object of class
bad_alloc.
-3- Notes:
The result of calling
what()
on the newly constructed object is implementation-defined.
-4- Effects:
Copies an object of class
bad_alloc.
-5- Returns:
An implementation-defined NTBS.
-1-
The type of a
handler function
to be called by
operator new()
or
operator new[]()
(lib.new.delete) when they cannot satisfy a request for additional storage.
-2- Required behavior:
A new_handler shall perform one of the following:
-1- Effects:
Establishes the function designated by new_p as the current
new_handler .
-2- Returns:
0 on the first call, the previous new_handler on subsequent calls.
-1-
The header
<typeinfo>
defines a
type associated with type information generated by the implementation.
It also defines two types for reporting dynamic type identification errors.
Header <typeinfo> synopsis
See also
expr.dynamic.cast, expr.typeid.
-1-
The class
type_info
describes type information generated by the implementation.
Objects of this class effectively store a pointer to a name for the type, and
an encoded value suitable for comparing two types for equality or collating order.
The names, encoding rule, and collating sequence for types are all unspecified
and may differ between programs.
-2- Effects:
Compares the current object with rhs .
-3- Returns:
true
if the two values describe the same type.
-4- Returns:
!(*this == rhs ).
-5- Effects:
Compares the current object with rhs .
-6- Returns:
true
if
*this
precedes rhs in the implementation's collation order.
-7- Returns:
an implementation-defined NTBS.
-8- Notes:
The message may be a null-terminated multibyte string (lib.multibyte.strings),
suitable for conversion and display as a
wstring
(lib.string.classes, lib.locale.codecvt)
-9- Effects:
Copies a
type_info
object.
-10- Notes:
Since the copy constructor and assignment operator for
type_info
are private to the class, objects of this type cannot
be copied.
-1-
The class
bad_cast
defines the type of objects thrown
as exceptions by the implementation to report the execution of an invalid
dynamic-cast
expression (expr.dynamic.cast).
-2- Effects:
Constructs an object of class
bad_cast.
-3- Notes:
The result of calling
what()
on the newly constructed object is implementation-defined.
-4- Effects:
Copies an object of class
bad_cast.
-5- Returns:
An implementation-defined NTBS.
-6- Notes:
The message may be a null-terminated multibyte string (lib.multibyte.strings),
suitable for conversion and display as a
wstring
(lib.string.classes, lib.locale.codecvt)
-1-
The class
bad_typeid
defines the type of objects
thrown as exceptions by the implementation to report a null pointer
in a
typeid
expression (expr.typeid).
-2- Effects:
Constructs an object of class
bad_typeid.
-3- Notes:
The result of calling
what()
on the newly constructed object is implementation-defined.
-4- Effects:
Copies an object of class
bad_typeid.
-5- Returns:
An implementation-defined NTBS.
-6- Notes:
The message may be a null-terminated multibyte string (lib.multibyte.strings),
suitable for conversion and display as a
wstring
(lib.string.classes, lib.locale.codecvt)
-1-
The header
<exception>
defines several types and functions related to the handling of exceptions in a C++ program.
Header <exception> synopsis
See also
except.special.
-1-
The class
exception
defines the base
class for the types of objects thrown as exceptions by
C++ Standard library components, and certain
expressions, to report errors detected during program execution.
-2- Effects:
Constructs an object of class
exception.
-3- Notes:
Does not throw any exceptions.
-4- Effects:
Copies an
exception
object.
-5- Notes:
The effects of calling
what()
after assignment are implementation-defined.
-6- Effects:
Destroys an object of class
exception.
-7- Notes:
Does not throw any exceptions.
-8- Returns:
An implementation-defined NTBS.
-9- Notes:
The message may be a null-terminated multibyte string (lib.multibyte.strings),
suitable for conversion and display as a
wstring
(lib.string.classes, lib.locale.codecvt)
-1-
The class
bad_exception
defines the type of objects thrown as
described in
(except.unexpected).
-2- Effects:
Constructs an object of class
bad_exception.
-3- Notes:
The result of calling
what()
on the newly constructed object is implementation-defined.
-4- Effects:
Copies an object of class
bad_exception.
-5- Returns:
An implementation-defined NTBS.
-6- Notes:
The message may be a null-terminated multibyte string (lib.multibyte.strings),
suitable for conversion and display as a
wstring
(lib.string.classes, lib.locale.codecvt)
-1-
The type of a
handler function
to be called by
unexpected()
when a function attempts to throw an exception not listed in its
exception-specification.
-2- Required behavior:
An
unexpected_handler
shall not return.
See also except.unexpected.
-3- Default behavior:
The implementation's default unexpected_handler calls
terminate().
-1- Effects:
Establishes the function designated by f as the current
unexpected_handler .
-2- Requires:
f shall not be a null pointer.
-3- Returns:
The previous unexpected_handler .
-1-
Called by the implementation when a function exits via an exception not allowed by its
exception-specification
(except.unexpected).
May also be called directly by the program.
-2- Effects:
Calls the
unexpected_handler
function in effect immediately after evaluating the
throw-expression
(lib.unexpected.handler),
if called by the implementation,
or calls the current
unexpected_handler,
if called by the program.
-1-
The type of a
handler function
to be called by
terminate()
when terminating exception processing.
-2- Required behavior:
A terminate_handler shall
terminate execution of the program without returning to the caller.
-3- Default behavior:
The implementation's default terminate_handler calls
abort().
-1- Effects:
Establishes the function designated by f as the current
handler function for terminating exception processing.
-2- Requires:
f shall not be a null pointer.
-3- Returns:
The previous terminate_handler .
-1-
Called by the implementation when exception
handling must be abandoned for any of several reasons (except.terminate).
May also be called directly by the program.
-2- Effects:
Calls the
terminate_handler
function in effect immediately after evaluating the
throw-expression
(lib.terminate.handler),
if called by the implementation,
or calls the current
terminate_handler
function, if called by the program.
-1- Returns:
true
after completing evaluation of a
throw-expression
until either completing initialization of the
exception-declaration
in the matching handler
or entering
unexpected()
due to the throw;
or after entering
terminate()
for any reason other than an explicit call to
terminate().
[Note:
This includes stack unwinding (except.ctor).
-2- Notes:
When
uncaught_exception()
is
true,
throwing an exception can result in a call of
terminate()
(except.terminate).
-1-
Headers
<cstdarg>
(variable arguments),
<csetjmp>
(nonlocal jumps),
<ctime>
(system clock
clock(), time()),
<csignal>
(signal handling),
and
<cstdlib>
(runtime environment
getenv(), system()).
-2-
The contents of these headers are the same as the Standard C library headers
<stdarg.h>,
<setjmp.h>,
<time.h>,
<signal.h>,
and
<stdlib.h>
respectively, with the following changes:
-3-
The restrictions that ISO C places on the second parameter to the
va_start()
macro in header
<stdarg.h>
are different in this International Standard.
The parameter
parmN
is the identifier of the rightmost parameter in the variable parameter list
of the function definition (the one just before the
...).
If the parameter
parmN
is declared with a function, array, or reference type, or with a type that
is not compatible with the type that results when passing an argument for
which there is no parameter, the behavior is undefined.
See also
ISO C subclause 4.8.1.1.
-4-
The function signature
longjmp(jmp_buf jbuf , int val )
has more restricted behavior in this International Standard.
If any automatic objects would be destroyed by a
thrown exception transferring control to another (destination) point in the
program, then a call to
longjmp( jbuf , val )
at the throw point that transfers control to the same
(destination) point has undefined behavior.
See also
ISO C subclause 7.10.4, 7.8, 7.6, 7.12.
-5-
The common subset of the C and C++ languages consists of all declarations,
definitions, and expressions that may appear in a well formed C++ program
and also in a conforming C program.
A POF (``plain old function'') is a function that uses only features from
this common subset, and that does not directly or indirectly use any
function that is not a POF.
All signal handlers shall have C linkage.
A POF that could be used as a signal handler in a conforming C program
does not produce undefined behavior when used as a signal handler in a
C++ program.
The behavior of any other function used as a signal handler in a
C++ program is implementation defined.*
static T epsilon() throw();
[Footnote:
Equivalent to FLT_EPSILON, DBL_EPSILON, LDBL_EPSILON.
--- end foonote]
static T round_error() throw();
[Footnote:
Rounding error is described in
ISO/IEC 10967-1 Language independent arithmetic - Part 1
Section 5.2.8 and
Annex A Rationale Section A.5.2.8 - Rounding constants.
--- end foonote]
static const int min_exponent;
[Footnote:
Equivalent to FLT_MIN_EXP, DBL_MIN_EXP, LDBL_MIN_EXP.
--- end foonote]
static const int min_exponent10;
[Footnote:
Equivalent to FLT_MIN_10_EXP, DBL_MIN_10_EXP, LDBL_MIN_10_EXP.
--- end foonote]
static const int max_exponent;
[Footnote:
Equivalent to FLT_MAX_EXP, DBL_MAX_EXP, LDBL_MAX_EXP.
--- end foonote]
static const int max_exponent10;
[Footnote:
Equivalent to FLT_MAX_10_EXP, DBL_MAX_10_EXP, LDBL_MAX_10_EXP.
--- end foonote]
static const bool has_infinity;
static const bool has_quiet_NaN;
[Footnote:
Required by LIA-1.
--- end foonote]
static const bool has_signaling_NaN;
[Footnote:
Required by LIA-1.
--- end foonote]
static const float_denorm_style has_denorm;
[Footnote:
Required by LIA-1.
--- end foonote]
denorm_absent
if the type does not allow denormalized values,
and
denorm_indeterminate
if it is indeterminate at compile time whether the type allows
denormalized values.
static const bool has_denorm_loss;
[Footnote:
See IEC 559.
--- end foonote]
static T infinity() throw();
[Footnote:
Required by LIA-1.
--- end foonote]
static T quiet_NaN() throw();
[Footnote:
Required by LIA-1.
--- end foonote]
static T signaling_NaN() throw();
[Footnote:
Required by LIA-1.
--- end foonote]
static T denorm_min() throw();
[Footnote:
Required by LIA-1.
--- end foonote]
static const bool is_iec559;
[Footnote:
International Electrotechnical Commission standard 559 is the same as
IEEE 754.
--- end foonote]
static const bool is_bounded;
[Footnote:
Required by LIA-1.
--- end foonote]
All built-in types are bounded, this member would be false for arbitrary
precision types.
static const bool is_modulo;
[Footnote:
Required by LIA-1.
--- end foonote]
A type is modulo if it is possible to add two positive numbers and have a result
that wraps around to a third number that is less.
static const bool traps;
[Footnote:
Required by LIA-1.
--- end foonote]
static const bool tinyness_before;
[Footnote:
Refer to IEC 559.
Required by LIA-1.
--- end foonote]
static const float_round_style round_style;
[Footnote:
Equivalent to FLT_ROUNDS.
Required by LIA-1.
--- end foonote]
18.2.1.3 - Type float_round_style [lib.round.style]
namespace std {
enum float_round_style {
round_indeterminate = -1,
round_toward_zero = 0,
round_to_nearest = 1,
round_toward_infinity = 2,
round_toward_neg_infinity = 3
};
}
18.2.1.4 - Type float_denorm_style [lib.denorm.style]
namespace std {
enum float_denorm_style {
denorm_indeterminate = -1;
denorm_absent = 0;
denorm_present = 1;
};
}
18.2.1.5 - numeric_limits specializations [lib.numeric.special]
namespace std {
template<> class numeric_limits<float> {
public:
static const bool is_specialized = true;
inline static float min() throw() { return 1.17549435E-38F; }
inline static float max() throw() { return 3.40282347E+38F; }
static const int digits = 24;
static const int digits10 = 6;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 2;
inline static float epsilon() throw() { return 1.19209290E-07F; }
inline static float round_error() throw() { return 0.5F; }
static const int min_exponent = -125;
static const int min_exponent10 = - 37;
static const int max_exponent = +128;
static const int max_exponent10 = + 38;
static const bool has_infinity = true;
static const bool has_quiet_NaN = true;
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
inline static float infinity() throw() { return ...; }
inline static float quiet_NaN() throw() { return ...; }
inline static float signaling_NaN() throw() { return ...; }
inline static float denorm_min() throw() { return min(); }
static const bool is_iec559 = true;
static const bool is_bounded = true;
static const bool is_modulo = false;
static const bool traps = true;
static const bool tinyness_before = true;
static const float_round_style round_style = round_to_nearest;
};
}
--- end example]
18.2.2 - C Library [lib.c.limits]
Type Name(s) Values: CHAR_BIT INT_MAX LONG_MIN SCHAR_MIN UCHAR_MAX USHRT_MAX CHAR_MAX INT_MIN MB_LEN_MAX SHRT_MAX UINT_MAX CHAR_MIN LONG_MAX SCHAR_MAX SHRT_MIN ULONG_MAX Type Name(s) Values: DBL_DIG DBL_MIN_EXP FLT_MIN_10_EXP LDBL_MAX_10_EXP DBL_EPSILON FLT_DIG FLT_MIN_EXP LDBL_MAX_EXP DBL_MANT_DIG FLT_EPSILON FLT_RADIX LDBL_MIN DBL_MAX FLT_MANT_DIG FLT_ROUNDS LDBL_MIN_10_EXP DBL_MAX_10_EXP FLT_MAX LDBL_DIG LDBL_MIN_EXP DBL_MAX_EXP FLT_MAX_10_EXP LDBL_EPSILON DBL_MIN FLT_MAX_EXP LDBL_MANT_DIG DBL_MIN_10_EXP FLT_MIN LDBL_MAX 18.3 - Start and termination [lib.support.start.term]
Type Name(s) Macros: EXIT_FAILURE EXIT_SUCCESS Functions: abort atexit exit
abort(void)
extern "C" int atexit(void (* f )(void))
extern "C++" int atexit(void (* f )(void))
exit(int status )
[Footnote:
Objects with automatic storage duration are all destroyed in a program whose
function
main()
contains no automatic objects and executes the call to
exit().
Control can be transferred directly to such a
main()
by throwing an exception that is caught in
main().
--- end foonote]
Functions registered with
atexit
are called in the reverse order of their registration.*
[Footnote:
A function is called for every time it is registered.
--- end foonote]
A function registered with
atexit
before an object
obj1
of static storage duration is initialized will not be called
until
obj1's
destruction has completed.
A function registered with
atexit
after an object
obj2
of static storage duration is initialized will be called
before
obj2's
destruction starts.
[Footnote:
Any C streams associated with
cin,
cout,
etc (lib.iostream.objects)
are flushed and closed when static objects are destroyed in the previous phase.
The function
tmpfile()
is declared in
<cstdio>.
--- end foonote]
[Footnote:
The macros
EXIT_FAILURE
and
EXIT_SUCCESS
are defined in
<cstdlib>.
--- end foonote]
18.4 - Dynamic memory management [lib.support.dynamic]
namespace std {
class bad_alloc;
struct nothrow_t {};
extern const nothrow_t nothrow;
typedef void (*new_handler)();
new_handler set_new_handler(new_handler new_p) throw();
}
void* operator new(std::size_t size) throw(std::bad_alloc);
void* operator new(std::size_t size, const std::nothrow_t&) throw();
void operator delete(void* ptr) throw();
void operator delete(void* ptr, const std::nothrow_t&) throw();
void* operator new[](std::size_t size) throw(std::bad_alloc);
void* operator new[](std::size_t size, const std::nothrow_t&) throw();
void operator delete[](void* ptr) throw();
void operator delete[](void* ptr, const std::nothrow_t&) throw();
void* operator new (std::size_t size, void* ptr) throw();
void* operator new[](std::size_t size, void* ptr) throw();
void operator delete (void* ptr, void*) throw();
void operator delete[](void* ptr, void*) throw();
18.4.1 - Storage allocation and deallocation [lib.new.delete]
18.4.1.1 - Single-object forms [lib.new.delete.single]
void* operator new(std::size_t size) throw(std::bad_alloc);
void* operator new(std::size_t size, const std::nothrow_t&) throw();
T* p1 = new T; //
throws bad_alloc if it fails
T* p2 = new(nothrow) T; // returns 0 if it fails
--- end example]
void operator delete(void* ptr) throw();
void operator delete(void* ptr, const std::nothrow_t&) throw();
18.4.1.2 - Array forms [lib.new.delete.array]
void* operator new[](std::size_t size) throw(std::bad_alloc);
[Footnote:
It is not the direct responsibility of
operator new[](std::size_t)
or
operator delete[](void*)
to note the repetition count or element size of the array.
Those operations are performed elsewhere in the array
new
and
delete
expressions.
The array
new
expression, may, however, increase the size argument to
operator new[](std::size_t)
to obtain space to store supplemental information.
--- end foonote]
void* operator new[](std::size_t size, const std::nothrow_t&) throw();
void operator delete[](void* ptr) throw();
void operator delete[](void* ptr, const std::nothrow_t&) throw();
[Footnote:
The value must not have been invalidated by an intervening call to
operator delete[](void*)
(lib.res.on.arguments).
--- end foonote]
For such a non-null value of ptr ,
reclaims storage allocated by the earlier call to the default
operator new[].
18.4.1.3 - Placement forms [lib.new.delete.placement]
void* operator new(std::size_t size, void* ptr) throw();
char place[sizeof(Something)];
Something* p = new (place) Something();
--- end example]
void* operator new[](std::size_t size, void* ptr) throw();
void operator delete(void* ptr, void*) throw();
void operator delete[](void* ptr, void*) throw();
18.4.2 - Storage allocation errors [lib.alloc.errors]
18.4.2.1 - Class bad_alloc [lib.bad.alloc]
namespace std {
class bad_alloc : public exception {
public:
bad_alloc() throw();
bad_alloc(const bad_alloc&) throw();
bad_alloc& operator=(const bad_alloc&) throw();
virtual ~bad_alloc() throw();
virtual const char* what() const throw();
};
}
bad_alloc() throw();
bad_alloc(const bad_alloc&) throw();
bad_alloc& operator=(const bad_alloc&) throw();
virtual const char* what() const throw();
18.4.2.2 - Type new_handler [lib.new.handler]
typedef void (*new_handler)();
18.4.2.3 - set_new_handler [lib.set.new.handler]
new_handler set_new_handler(new_handler new_p ) throw();
18.5 - Type identification [lib.support.rtti]
namespace std {
class type_info;
class bad_cast;
class bad_typeid;
}
18.5.1 - Class type_info [lib.type.info]
namespace std {
class type_info {
public:
virtual ~type_info();
bool operator==(const type_info& rhs ) const;
bool operator!=(const type_info& rhs ) const;
bool before(const type_info& rhs ) const;
const char* name() const;
private:
type_info(const type_info& rhs );
type_info& operator=(const type_info& rhs );
};
}
bool operator==(const type_info& rhs ) const;
bool operator!=(const type_info& rhs ) const;
bool before(const type_info& rhs ) const;
const char* name() const;
type_info(const type_info& rhs );
type_info& operator=(const type_info& rhs );
18.5.2 - Class bad_cast [lib.bad.cast]
namespace std {
class bad_cast : public exception {
public:
bad_cast() throw();
bad_cast(const bad_cast&) throw();
bad_cast& operator=(const bad_cast&) throw();
virtual ~bad_cast() throw();
virtual const char* what() const throw();
};
}
bad_cast() throw();
bad_cast(const bad_cast&) throw();
bad_cast& operator=(const bad_cast&) throw();
virtual const char* what() const throw();
18.5.3 - Class bad_typeid [lib.bad.typeid]
namespace std {
class bad_typeid : public exception {
public:
bad_typeid() throw();
bad_typeid(const bad_typeid&) throw();
bad_typeid& operator=(const bad_typeid&) throw();
virtual ~bad_typeid() throw();
virtual const char* what() const throw();
};
}
bad_typeid() throw();
bad_typeid(const bad_typeid&) throw();
bad_typeid& operator=(const bad_typeid&) throw();
virtual const char* what() const throw();
18.6 - Exception handling [lib.support.exception]
namespace std {
class exception;
class bad_exception;
typedef void (*unexpected_handler)();
unexpected_handler set_unexpected(unexpected_handler f ) throw();
void unexpected();
typedef void (*terminate_handler)();
terminate_handler set_terminate(terminate_handler f ) throw();
void terminate();
bool uncaught_exception();
}
18.6.1 - Class exception [lib.exception]
namespace std {
class exception {
public:
exception() throw();
exception(const exception&) throw();
exception& operator=(const exception&) throw();
virtual ~exception() throw();
virtual const char* what() const throw();
};
}
exception() throw();
exception(const exception&) throw();
exception& operator=(const exception&) throw();
virtual ~exception() throw();
virtual const char* what() const throw();
18.6.2 - Violating exception-specifications [lib.exception.unexpected]
18.6.2.1 - Class bad_exception [lib.bad.exception]
namespace std {
class bad_exception : public exception {
public:
bad_exception() throw();
bad_exception(const bad_exception&) throw();
bad_exception& operator=(const bad_exception&) throw();
virtual ~bad_exception() throw();
virtual const char* what() const throw();
};
}
bad_exception() throw();
bad_exception(const bad_exception&) throw();
bad_exception& operator=(const bad_exception&) throw();
virtual const char* what() const throw();
18.6.2.2 - Type unexpected_handler [lib.unexpected.handler]
typedef void (*unexpected_handler)();
18.6.2.3 - set_unexpected [lib.set.unexpected]
unexpected_handler set_unexpected(unexpected_handler f ) throw();
18.6.2.4 - unexpected [lib.unexpected]
void unexpected();
18.6.3 - Abnormal termination [lib.exception.terminate]
18.6.3.1 - Type terminate_handler [lib.terminate.handler]
typedef void (*terminate_handler)();
18.6.3.2 - set_terminate [lib.set.terminate]
terminate_handler set_terminate(terminate_handler f ) throw();
18.6.3.3 - terminate [lib.terminate]
void terminate();
18.6.4 - uncaught_exception [lib.uncaught]
bool uncaught_exception();
--- end note]
18.7 - Other runtime support [lib.support.runtime]
Type Name(s) Macros: va_arg va_end va_start Type: va_list Type Name(s) Macro: setjmp Type: jmp_buf Function: longjmp Type Name(s) Macros: CLOCKS_PER_SEC Types: clock_t Functions: clock Type Name(s) Macros: SIGABRT SIGILL SIGSEGV SIG_DFL SIG_IGN SIGFPE SIGINT SIGTERM SIG_ERR Type: sig_atomic_t Functions: raise signal Type Name(s) Functions: getenv system [Footnote:
In particular, a signal handler using exception handling is very
likely to have problems
--- end foonote]