This book is for C++ programmers who are frustrated with some of the limitations of the standard C++ library. The book is a tutorial and reference for the library described in the first C++ Library Technical Report, which was approved in 2006 by the International Organization for Standardization (ISO). The library, except for the special math functions, has also been added to the draft working paper for the next C++ standard. It extends the standard C++ library with new facilities in several areas:
tuple
that generalizes the std::pair
class template to handle various numbers of argumentsThe book has nearly 200 example programs. You can download an archive file with all of the examples here. If you have questions or comments about the book, please send them to tr1book@petebecker.com.
j
. Its actual type is
const int&
; that is, j
cannot be modified through
that reference.show
is a little confusing. Before the call to
sp0.reset()
, the object sp0
is empty. The call to
show
that follows this call to reset
shows the effect
of calling reset
on an empty object.show
are a little confusing. Before the
call to sp0.reset(new resource(1))
, the object sp0
is empty. The call to show
that follows this call to reset
shows the effect of calling reset
on an empty object. After that call,
sp0
is not empty, so the final call to show
shows the
effect of calling reset
on a non-empty object.shared_ptr
. They should both refer to
weak_ptr
.(&a)-> X();
should be (&a)->~X();
.b
’s
controlled sequence. It should be a copy of a
’s controlled
sequence.const_ local_iterator
. The space does not
belong there. It should be const_local_iterator
.value_type
is the same as the type held by the container. The
actual requirement is less strict: the range’s value_type
must
be convertible to the type held by the container.(d.*f)(1.0)
should be
(d.*g)(1.0)
and (br.*f)(1.0, 2.0)
should be
(br.*h)(1.0, 2.0)
.operator()
in the synopsis for reference_wrapper
uses
a type named T
that is not defined.
result_of<T(T1, T2, ... TN)>
should be
result_of<Ty(T1, T2, ... TN)>
.bind
to create a predicate
that is true whenever its argument is less than 10, not when its argument is
greater than or equal to 10.sph_legendre
at the top of the page is incorrect. Replace
i*m*theta
with i*m*phi
.<random>
use types named sint
,
uint
, and i-type
. Those names represent
implementation-specific integral types that are large enough to hold the
generator’s values. The first is a signed integral type, the
second is an unsigned integral type, and the third is a signed or
unsigned integral type.mersenne_twister
lists a member function void
seed();
and a member function void seed(unsigned long x0 =
5489);
. With both of these overloads, a call to
seed()
would be ambiguous. Ignore void
seed();
."((a+)(b+))(c+)"
.rgy("a*b")
should be rgy(rgx)
.basic_string<char_type
is missing its final >
.regex_replace
, which takes
a string
object as its first argument. The actual code passes
an insert iterator. To pass the string
object, in the call to
regex_replace
change back_inserter(result)
to
result
.printf
in the
code snippets a few extra backslashes crept in. Where the format string
says \%u
it should say %u
.using std::hexfloat;
. That should be
using std::tr1::hexfloat;
.