Home > Store

C++ Standard Template Library, The

Register your product to gain access to bonus material or receive a coupon.

C++ Standard Template Library, The

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2001
  • Dimensions: 7" x 9-1/4"
  • Pages: 512
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-437633-1
  • ISBN-13: 978-0-13-437633-2

With the ANSI/ISO C++ Standard Template Library (STL), C++ developers have a powerful toolset for maximizing productivity, software quality, and performance at the same time. STL provides both comprehensive sets of container classes and fundamental algorithms to go with them-a large, systematic, and efficient framework for C++ development. Now, in this long-awaited book, the creators of the C++ Standard Template Library explain it authoritatively and in depth. Each chapter of The C++ Standard Template Library covers one STL component, including:

  • Detailed background about the component and its uses
  • A thorough review of the relevant ANSI/ISO C++ standard
  • Practical techniques for using and implementing the component
  • Extensive sample code
  • Hands-on exercises

Appendices present lists of reserved names, a detailed glossary of terms and references, and how STL interfaces with the rest of the Standard C++ library.

Fully reflective of the final ANSI/ISO STL standard, The C++ Standard Template Library is the last word on all aspects of STL development for every experienced C++ programmer.

Sample Content

Downloadable Sample Chapter

Click here for a sample chapter for this book: 0134376331.pdf

Table of Contents



0. Introduction.

Background. Functional Description. Using STL. Implementing STL. Testing STL. Exercises.



1. Iterators.

Background. Functional Description. Using Iterators. Exercises.



2. <utility>.

Background. Functional Description. Using <utility>. Implementing <utility>. Testing <utility>. Exercises.



3. <iterator>.

Background. Functional Description. Using <iterator>. Implementing <iterator>. Testing <iterator>. Exercises.



4. <memory>.

Background. Functional Description. Using <memory>. Implementing <memory>. Testing <memory>. Exercise.



5. Algorithms.

Background. Functional Description. Using Algorithms. Exercises.



6. <algorithm>.

Background. Functional Description. Using <algorithm>. Implementing <algorithm>. Testing <algorithm>. Exercises.



7. <numeric>.

Background. Functional Description. Using <numeric>. Implementing <numeric>. Testing <numeric>. Exercises.



8. <functional>.

Background. Functional Description. Using <functional>. Implementing <functional>. Testing <functional>. Exercises.



9. Containers.

Background. Functional Description. Using Containers. Exercises.



10. <vector>.

Background. Functional Description. Using <vector>. Implementing <vector>. Testing <vector>. Exercises.



11. <list>.

Background. Functional Description. Using <list>. Implementing <list>. Testing <list>. Exercises.



12. <deque>.

Background. Functional Description. Using <deque>. Implementing <deque>. Testing <deque>. Exercises.



13. <set>.

Background. Functional Description. Using <set>. Implementing <set>. Testing <set>. Exercises.



14. <map>.

Background. Functional Description. Using <map>. Implementing <map>. Testing <map>. Exercises.



15. <stack>. Background. Functional Description. Using <stack>. Implementing <stack>. Testing <stack>. Exercises.


16. <queue>.

Background. Functional Description. Using <queue>. Implementing <queue>. Testing <queue>. Exercises.



Appendix A: Interfaces.


Appendix B: Terms.


Appendix C: References.


Index.

Preface

Preface

The Standard Template Library (or STL for short) is a major component of the library portion of the ANSI/ISO Standard for the programming language C++. It was developed at Hewlett-Packard Labs by Alexander Stepanov and Meng Lee (S&L95), based heavily on earlier work by Stepanov and David R. Musser of Rensselaer Polytechnic Institute. (See M&S87, M&S89, and M&S94. All citations are listed in Appendix C: References.) You will find this software package to be a most ambitious, and coherent, use of templates in C++. Indeed, STL has already begun to alter significantly the way many programmers write C++ code.

This book shows you how to use the template classes and functions of STL as mandated by the C++ Standard (clauses 20 and 23-26). We focus here on STL as a fairly self-contained subset of a larger library defined for Standard C++. That library is designed to work, in turn, with the library defined for ANSI/ISO Standard C (ANS89 and ISO90). Consequently, you can look on this book as a companion to two earlier works by P.J. Plauger, The Standard C Library (Pla92) and The Draft Standard C++ Library (Pla95). Taken together, these three books describe nearly all the library facilities of widespread interest to C++ programmers.

C++ Standard

The C++ Standard was formally approved in 1998 and should be stable for years to come. It is both an ANSI Standard (within the USA) and an ISO Standard (around the world). As part of the standardization process, the entire Standard C++ language and library were for the first time described completely and in one place. A relatively late event in that process was the incorporation of STL as part of the draft C++ Standard. More recent still is the wider dissemination of various implementations of Standard C++ compilers and libraries. Thus, much of what you will find in this book is news, even to experienced C++ programmers.

Similarly, the description of STL (precursors to S&L95) saw only limited circulation before its incorporation into the draft C++ Standard of July 1994. In the process of incorporation, it has been reorganized and changed in several significant ways. The STL in Standard C++ is not the package made widely available by Hewlett-Packard. It is not the version more recently enhanced by many different agencies. Thus, even programmers with early experience using STL can profit from this book. You will find here a complete presentation of STL as it is specified by the C++ Standard.

The book also shows you at least one way to implement STL. We present about 6,000 lines of tested, working code that is known to be portable across a number of C++ compilers. It is, in fact, essentially the same code that you will find distributed with Microsoft Visual C++, IBM Visual Age, as well as with C++ compilers offered by a number of other vendors. Minor changes have been made in formatting and notation, to make the book form of the code more readable and tutorial.

To a large extent, the code presented here works atop any C++ library. (See Appendix A: Interfaces.) It is designed to work particularly well, however, with a library that conforms closely to the C++ Standard. As much as possible, the code avoids forms that are non portable or not likely to be widely available. Code that relies on recent additions to the C++ language, such as template partial specialization, may still present problems with some compilers. You will find that commercial versions of this library indulge in various compromises to deal with such dialect issues.

One way or another, you can use the code presented here to gain valuable experience using a library of templates that is well on its way to becoming an important standard for the C++ world. Equally important, we believe that seeing a realistic implementation of STL can help you better under-stand how to use it.

And that introduces yet another goal. Besides presenting STL as standardized, and working code to implement it, this book also serves as a tutorial on how to use this library. You will find here useful background information on how the library came to take its present form, how it was meant to be used, and how it should be used. You don't have to read and understand all the code presented here to achieve that basic goal. Even a cursory study is beneficial. You certainly don't have to be a sophisticated user to profit from this book, but the programmer who is just an occasional sophisticate will find the information presented here invaluable.

Teaching you how to write C++ is not a goal of this book. We assume you know enough about C++ to read straightforward code. Where the code presented is not so straightforward, we explain the trickery involved.

extending STL

A final purpose of this book is to teach programmers how to design and implement extensions to the Standard Template Library. STL brings to-gether numerous algorithms, data structures, and programming tech-niques. It is not, however, intended to supply a complete set of facilities that a programmer might need. Rather, it provides a core of the most widely used facilities. And it describes the rules by which this core code is written. Once you learn to follow these rules, you can add your own algorithms that work with existing data structures. You can also add data structures that work with existing algorithms. Using the STL code presented here as an example, you will soon learn how to tackle new problems by writing a minimum of new code. And you will find that the new code is itself often reusable on future projects. That's what library design is all about, in the end.

structure of this book

The book is structured much like the STL code itself. The C++ Standard specifies numerous headers, but only thirteen of these headers define all the templates in STL. A separate chapter covers each header. Additional chapters introduce STL as a whole and discuss three overarching topics — iterators, algorithms, and containers. Most of the headers have reasonably cohesive contents. That makes for reasonably cohesive discussions. One or two, however, are catchalls. Their corresponding chapters are perforce wider ranging.

Each chapter that describes a header follows the same pattern. It begins with a brief background section, followed by a functional description of the header contents, then by suggestions for how best to use the facilities defined in the header. We then present the C++ code that constitutes the header itself, accompanied by a commentary on how the code works. We also present a small test program for each header, to provide at least a cursory example of how each template definition might be used.

Each chapter ends with a set of exercises. In a university course based on this book, the exercises can serve as homework problems. Many of them are simple exercises in using the library, or in code rewriting. They drive home a point or illustrate reasonable variations in implementation. The more ambitious exercises are labeled as such. They can serve as a basis for more extended projects. The independent reader can use the exercises as stimulus for further thought.

The Code

The code presented in this book and its description are based on the version of STL made widely available by Hewlett-Packard Company. That version contains the following notice:

Copyright (c) 1994 by Hewlett-Packard Company
Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Hewlett-Packard Company makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

The code in this book has been tested, to various degrees, with C++ compilers from Microsoft, IBM, Edison Design Group, and Project GNU. It passes all the STL tests in the Dinkum C++ Proofer and the Dinkum Abridged Proofer, both quality-assurance tools for the corresponding libraries available commercially from Dinkumware, Ltd. It has also passed various versions of the commercial library validation suites available from Perennial Software and Plum Hall Inc. While we have taken pains to minimize errors, we cannot guarantee that none remain. Please note carefully the disclaimer on the copyright page.

Please note also that the code in this book is protected by copyright. It has not been placed in the public domain. Nor is it shareware. It is not protected by a "copy left" agreement, like code distributed by the Free Software Foundation (Project GNU). P.J. Plauger retains all rights. Dinkumware, Ltd. licenses it on a commercial basis.

The STL code that comes with a given C++ compiler may differ from the code presented here in various ways. This is true even of code based on that presented here. Dialects of C++ still abound, particularly in the complex area of template processing. Over time, all these dialects should converge, thanks to the completion of the C++ Standard. But for some time to come, you should consider the code presented here as reasonably representative of many implementations.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020