The C++ Standard Library Extensions and over one million other books are available for Amazon Kindle. Learn more


or
Sign in to turn on 1-Click ordering.
or
Amazon Prime Free Trial required. Sign up when you check out. Learn More
Kindle Edition
 
   
Sell Back Your Copy
For a $6.00 Gift Card
Trade in
More Buying Choices
Have one to sell? Sell yours here
The C++ Standard Library Extensions: A Tutorial and Reference
 
 
Start reading The C++ Standard Library Extensions on your Kindle in under a minute.

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.

The C++ Standard Library Extensions: A Tutorial and Reference [Hardcover]

Pete Becker (Author)
4.0 out of 5 stars  See all reviews (3 customer reviews)

List Price: $64.99
Price: $48.20 & this item ships for FREE with Super Saver Shipping. Details
You Save: $16.79 (26%)
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
In Stock.
Ships from and sold by Amazon.com. Gift-wrap available.
Only 9 left in stock--order soon (more on the way).
Want it delivered Wednesday, February 1? Choose One-Day Shipping at checkout. Details

Formats

Amazon Price New from Used from
Kindle Edition $41.07  
Hardcover $48.20  
Paperback --  

Book Description

July 31, 2006

"TR1 roughly doubles the size of the C++ standard library, and it introduces many new facilities and even new kinds of library components. TR1 has some classes, for example, where some nested types may or may not exist depending on the template arguments. To programmers whose experience stops with the standard library, this is strange and unfamiliar. This book is complete (it covers all TR1 facilities), it is easier to understand than TR1 itself, and it is technically accurate."
--Matthew Austern,software engineer, Google

"TR1 will help make the C++ programmer more productive than ever. In this book, Pete Becker has written the ultimate reference guide to these components, what they are, how they work, and what they're used for. This book should be on the bookshelf of anyone who wants to use these standardized components to improve both their productivity as well as their coding quality."
--John Maddock, consultant and programmer

The current C++ standard library extends the core C++ language with common classes and functions. In recent years, to address limitations in that library, a number of components have been developed to extend the language even further. Compiled in a comprehensive technical report (TR1), the bulk of these extensions have been approved for the next revision of the C++ standard.

In this book, Pete Becker describes in detail each component in the TR1 library, explaining new facilities for utilities, containers, call wrappers, type traits, numerics, regular expressions, and C compatibility. He draws on his own experience implementing these components to illustrate their value, clarifying the specifications when necessary and providing complete, tested code examples.

Most chapters include exercises of various degrees of difficulty to help programmers get hands-on practice with the new components. Answers to the exercises, along with all code examples, are available on the Web. Appendixes comprise a summary of headers included in or extended by the TR1 library, as well as guidelines on how to use the components safely in multithreaded applications.

The C++ Standard Library Extensions is for any programmer who wants to get a jump on the revised standard. It also makes the perfect companion to The C++ Standard Library, by Nicolai Josuttis, both books being tutorials and references essential for using C++ more effectively.




Frequently Bought Together

Customers buy this book with The C++ Standard Library: A Tutorial and Reference $51.63

The C++ Standard Library Extensions: A Tutorial and Reference + The C++ Standard Library: A Tutorial and Reference
  • This item: The C++ Standard Library Extensions: A Tutorial and Reference

    In Stock.
    Ships from and sold by Amazon.com.
    This item ships for FREE with Super Saver Shipping. Details

  • The C++ Standard Library: A Tutorial and Reference

    In Stock.
    Ships from and sold by Amazon.com.
    This item ships for FREE with Super Saver Shipping. Details



Editorial Reviews

About the Author

Pete Becker is an independent consultant specializing in library design and implementation. He previously worked at Dinkumware, Ltd., where he wrote the technical documentation for, and completed the implementation of, all aspects of the TR1 library. A member of the ISO C++ Standards committee since its inception, Pete is now the project editor for C++0x.



Excerpt. © Reprinted by permission. All rights reserved.

He who has begun has half done. Dare to be wise; begin!
—Epistles, I, ii, Horace

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).1 This library, which I’ll call the TR1 library, isn’t part of the C++ Standard. The TR is only “an informative document,” but you can expect to see the library shipped with some compilers and provided as an add-on library from various library vendors. You can also expect to see many of its components incorporated into the standard library in the next C++ standard.2

The TR1 library extends the standard C++ library with new facilities in several areas:

  • Utilities: a reference-counted smart pointer; a class template tuple that generalizes the std::pair class template to handle various numbers of arguments
  • Containers: sets and maps implemented with hash tables; a fixed-size array
  • Call wrappers: more powerful and more flexible templates that provide wrappers around functions, member functions, and other function objects, allowing them to be used more easily as arguments to algorithms
  • Type traits: a set of templates that extract properties of types or modify types at compile time, simplifying template metaprogramming
  • Numerics: a rich set of random number generators; advanced mathematical special functions; numeric facilities like those added to the C language in 1999
  • Regular expressions: classes and functions to describe and search for patterns in text
  • C compatibility: types, functions, and macros like those added to the C language in 1995 and 1999

Formal work on the TR1 library began in 2001, when the C++ Standards Committee, through its Library Working Group, asked for proposals. Most of the proposals that made it into the library came from members of Boost,3 an organization set up in 1998 by Standards Committee members who were looking for a way to develop new libraries without the constraints imposed by the process of standardization. The added flexibility from working outside that formal process made it possible to develop the pieces of the Boost libraries on independent schedules far more rapidly than is possible within a standards committee. Boost is a thriving organization, and its library has many useful things that are not in the TR1 library.

The Standards Committee meets twice a year. From 2001 to 2005, the Library Working Group spent most of its time at those meetings, as well as a great deal of e-mail time between meetings, working on the TR1 library. During that time, the working group refined the proposals it had received: simplifying where appropriate, rewriting both for clarity and for the formalism required in an ISO standard, and unifying the presentation of the pieces of the library.

Toward the end of 2002, the company I worked for, Dinkumware, Ltd., began implementing the TR1 library. Dinkumware sells standard libraries for C, C++, and Java, so this was a natural step for us. Our work also helped improve the Technical Report, as we found things that were vaguely described, overspecified, or simply missing.4 Dinkumware has a complete implementation of the TR1 library, and I’ve used it in all the examples in this book.

About This Book

This book is divided into seven parts, each one covering one area of the new facilities. Each part begins with an overview of those facilities. The overview usually includes some remarks about their history and, in some cases, reasons why some obvious features are not in the TR1 library.

Each part has a synopsis of the header or headers that define the librarycomponents discussed in that part. The synopsis is not, in general, compilable code but instead presents an overview of the components that the header defines, listing all the templates, classes, non-member functions, objects, constants, and so on, that are defined in that header. Each of those things is defined in more detail later. However, even the more detailed definitions often are not compilable code. Many of the details are implementation dependent, and nothing would be gained by slogging through them.

Each synopsis is highlighted in gray. Most are followed by the formal requirements from the C++ standard. These formal requirements are indented. Informal discussions are not indented.

Most chapters end with a set of exercises that review the concepts covered in the chapter. Some exercises are easy, and some are deliberately difficult. Don’t worry if you can’t solve all of them.

To avoid confusion, I often use formal language to identify the things that I’m talking about. It’s far too common for discussions to bog down because the participants don’t know whether they’re talking about templates, classes, or objects. For example, the TR1 library has a template named function that holds function objects. Rather than make you guess whether the word function refers to that template or to an object created from that template, I’ve tried to consistently use such phrases as “the class template function,” “specialization of the class template function,” and “object of type function.”

All the code examples are complete: They will compile with a suitable compiler and library. Examples that have a main function will also link and run. The examples have been tested with Microsoft’s C/C++ compiler,5 version 7.1; and with the GNU Project’s gcc compiler,6 version 3.4.3, using the Dinkum TR1 Library Version 1.0 from Dinkumware, Ltd.7 Source code for the examples can be downloaded from my Web site.8

ISO, Conformance, and the TR1 library

The ISO C++ standard is a specification for the C++ programming language, defining what is and is not a valid C++ program and for valid programs telling you, within certain limits, what that program should do. The TR1 library is not part of the C++ standard, although most of the library will almost certainly become part of the standard in its next revision, around 2010. In the meantime, compilers that conform to the C++ standard do not need to include the TR1 library.9

The standard defines and uses several technical terms to talk about valid and invalid programs and about the meaning of a valid program. The Library Technical Report uses the same terminology. Programmers are often confused about the meanings of these terms.10 They’re not particularly complicated, though, so if you’re interested, read on.

A diagnostic message is any compiler11 output message that results from a violation of the rules that the standard sets out. The compiler is allowed to give other messages as well, but the compiler’s documentation is required to tell you which messages are diagnostic messages.

When the standard says that some code results in undefined behavior, it means that the standard does not impose any requirements on what a compiler does when compiling a program that uses that code. Unfortunately, code whose behavior is undefined often results in a program that does exactly what you thought it would do but only until you change to a different compiler. This makes debugging very difficult, so it’s best to avoid writing code whose behavior is undefined.

A diagnosable rule is any standard rule that doesn’t say “no diagnostic required” and that doesn’t result in undefined behavior. If your code violates a rule that doesn’t require a diagnostic, the standard allows your compiler to do anything at all; you’ve done something that the C++ standard does not recognize, so you’re on your own. If your code violates a diagnosable rule, the compiler must issue at least one diagnostic message.12 That doesn’t mean that the compiler must report every diagnosable error; nor does it mean that it cannot give diagnostic messages when compiling a program without diagnosable errors. Technically, a compiler that reports “an error occurred” every time you compile code meets the requirements of the C++ standard. Of course, nobody would use a compiler that did that, if they could avoid it.

The One Definition Rule requires that definitions of things that ought to be the same must in fact be the same. For example, if you define a struct named data with two members of type int in one source file and you define a struct named data with three members of type double in another source file, you’ve violated the One Definition Rule. Such violations don’t require a diagnostic. They can lead to very mysterious problems.

A well-formed program is one that doesn’t violate any diagnosable rule and doesn’t violate the One Definition Rule. An ill-formed program is one that isn’t well formed.

Because they run on systems with finite amounts of storage, compilers have resource limits, which prevent them from compiling programs that are too complicated. The C++ standard recommends some minimum values for such things as the maximum nesting level of compound statements (256), the maximum number of case labels for a switch statement (16,384), and the maximum number of nested template instantiations (17). Compilers are required to document these limits when they are known. These days, however, compilers are getting away from fixed-size tables, instead allocating their internal data structures dynamically as needed; this means tha...


Product Details

  • Hardcover: 624 pages
  • Publisher: Addison-Wesley Professional; 1 edition (July 31, 2006)
  • Language: English
  • ISBN-10: 0321412990
  • ISBN-13: 978-0321412997
  • Product Dimensions: 9.5 x 7.6 x 1.4 inches
  • Shipping Weight: 2.4 pounds (View shipping rates and policies)
  • Average Customer Review: 4.0 out of 5 stars  See all reviews (3 customer reviews)
  • Amazon Best Sellers Rank: #851,650 in Books (See Top 100 in Books)

More About the Author

Discover books, learn about writers, read author blogs, and more.

 

Customer Reviews

3 Reviews
5 star:
 (2)
4 star:    (0)
3 star:    (0)
2 star:
 (1)
1 star:    (0)
 
 
 
 
 
Average Customer Review
4.0 out of 5 stars (3 customer reviews)
 
 
 
 
Share your thoughts with other customers:
Most Helpful Customer Reviews

29 of 31 people found the following review helpful:
2.0 out of 5 stars Lacking as a Tutorial and Reference, October 10, 2008
Amazon Verified Purchase(What's this?)
This review is from: The C++ Standard Library Extensions: A Tutorial and Reference (Hardcover)
The subtitle of this book is "A Tutorial and Reference". As a tutorial, I found this book to be lacking. The explanations are terse, quite unlike the more user-friendly tutorial style of Nicolai Josuttis in "C++ Standard Library".

Second, as a reference, this book is also lacking on two counts. The index is incomplete! In the first month of use, I discovered major omissions in the index! Also, the formatting of the function listings makes it difficult to find a particular function by browsing through the section. Sometimes it takes minutes.

The author knows his material, and the information is accurate. I have not encountered any errors in the text, and it seems to be complete. But this book does not live up to the quality of its predecessor text, mentioned above. And it does not live up to its subtitle.

No doubt this review will be voted down by people trying to sell the book, but there you have it -- details and specifics.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


17 of 18 people found the following review helpful:
5.0 out of 5 stars A "must have" book for C++ programmers, September 5, 2006
By 
Beman Dawes (Onancock, VA USA) - See all my reviews
(REAL NAME)   
This review is from: The C++ Standard Library Extensions: A Tutorial and Reference (Hardcover)
This will become a "must have" book for C++ programmers. It is both easy to understand and authoritative at the same time. It will be useful for a long, long time, first as a learning tool and then as a reference.

Implementations of TR1 are now available from Boost (free) and Dinkumware (reasonably priced), so these library components are something that a C++ programmer can start using right away. Most or all of them will also be part of the next standard, so they are sure to become ever more widely used.

I like the fact the book is hard-cover, since it is likely to get a lot of use. Maybe I'm old fashioned, but I still think a book like this is the easiest way to study something new, and really learn about it.

I already posted one review, but Amazon seems to have lost it. I'm surprised there haven't been more reviews posted - the book deserves more.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


16 of 19 people found the following review helpful:
5.0 out of 5 stars many improvements and exercises, August 24, 2006
This review is from: The C++ Standard Library Extensions: A Tutorial and Reference (Hardcover)
There are many, perhaps too many, books on C++. But Becker breaks new ground. He presents what is coming down the road towards the current C++ programmer. The existing C++ standard library is good but limited. The widespread use of C++ led to recognition of useful classes that should be in this library but are not. After some years of dilly dallying, Technical Report 1 was produced. Work started in 2001. Six years!

This book explains the classes in TR1. While it is not guaranteed that all of TR1 will make it into the next official standard library, most certainly will. The only real question is when that revision will be released. Given the way C++ changes so slowly, don't hold your breath.

In the interim, you can make good professional use of your time by studying TR1 via this book. It's not a simple rendition of the classes. Becker devotes considerable space to explaining the usages of the new classes. Giving you the gist of what they are about. Just as importantly, each chapter has a set of exercises involving its classes. Tackling these is probably the best way to gain experience.

Of the new classes, what interests you most will vary with the reader. Personally, I was most impressed with the Numerics. Huge improvements in dealing with floats and overflows (NaNs). And for physicists or engineers, there are specialised functions that will save some coding. Laguerre polynomials, Legendre functions, gamma functions, Bessel functions and Hermite polynomials, amongst others. A far richer set than what you currently get in the standard library.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No

Share your thoughts with other customers: Create your own review
 
 
 
Only search this product's reviews



What Other Items Do Customers Buy After Viewing This Item?


Tags Customers Associate with This Product

 (What's this?)
Click on a tag to find related items, discussions, and people.
 
(2)

Your tags: Add your first tag
 

Customer Discussions

This product's forum
Discussion Replies Latest Post
No discussions yet

Ask questions, Share opinions, Gain insight
Start a new discussion
Topic:
First post:
Prompts for sign-in
 


Active discussions in related forums
Search Customer Discussions
Search all Amazon discussions
   
Related forums





Look for Similar Items by Category


Look for Similar Items by Subject