Watch the Amazon Original series Cross now on Prime Video. Yours with Prime.
Buy used:
$19.89
Get Fast, Free Shipping with Amazon Prime
to get FREE delivery Friday, November 22. Order within 3 hrs 35 mins
Or Non members get FREE delivery Sunday, November 24 on orders shipped by Amazon over $35
Used: Good | Details
Sold by RAK Goods
Condition: Used: Good
Comment: No writing and no highlighting. Some minor edge wear to edges/corners. Otherwise clean covers with pages that lay flat. Fast shipping by Amazon!
Access codes and supplements are not guaranteed with used items.
Kindle app logo image

Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet, or computer - no Kindle device required.

Read instantly on your browser with Kindle for Web.

Using your mobile phone camera - scan the code below and download the Kindle app.

QR code to download the Kindle App

Follow the author

Something went wrong. Please try your request again later.

Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library 1st Edition

4.5 4.5 out of 5 stars 167 ratings

“This is Effective C++ volume three – it’s really that good.”
– Herb Sutter, independent consultant and secretary of the ISO/ANSI C++ standards committee “There are very few books which all C++ programmers
must have. Add Effective STL to that list.”
– Thomas Becker, Senior Software Engineer, Zephyr Associates, Inc., and columnist,
C/C++ Users Journal

C++’s Standard Template Library is revolutionary, but learning to use it well has always been a challenge. Until now. In this book, best-selling author Scott Meyers (Effective C++, and More Effective C++) reveals the critical rules of thumb employed by the experts – the things they almost always do or almost always avoid doing – to get the most out of the library.

Other books describe what’s in the STL. Effective STL shows you how to use it. Each of the book’s 50 guidelines is backed by Meyers’ legendary analysis and incisive examples, so you’ll learn not only what to do, but also when to do it – and why.

Highlights of Effective STL include:

  • Advice on choosing among standard STL containers (like vector and list), nonstandard STL containers (like hash_set and hash_map), and non-STL containers (like bitset).
  • Techniques to maximize the efficiency of the STL and the programs that use it.
  • Insights into the behavior of iterators, function objects, and allocators, including things you should not do.
  • Guidance for the proper use of algorithms and member functions whose names are the same (e.g., find), but whose actions differ in subtle (but important) ways.
  • Discussions of potential portability problems, including straightforward ways to avoid them.

Like Meyers’ previous books, Effective STL is filled with proven wisdom that comes only from experience. Its clear, concise, penetrating style makes it an essential resource for every STL programmer.


Amazon First Reads | Editors' picks at exclusive prices

Editorial Reviews

Amazon.com Review

Written for the intermediate or advanced C++ programmer, renowned C++ expert Scott Meyers provides essential techniques for getting more out of the Standard Template Library in Effective STL, a tutorial for doing more with this powerful library.

STL is a hugely powerful feature of today's C++, but one with a well-earned reputation for complexity. The book is organized into 50 tips that explore different areas of the STL. Besides providing a list of dos and don'ts, Meyers presents a lot of background on what works and what doesn't with STL. Each tip is demonstrated with in-depth coding samples, many of which make use of two-color printing to highlight the most important lines of code. (Advanced developers will enjoy Meyers's in-depth explanations, while those who are in a hurry can skip ahead to the recommended tip itself.)

A good part of this book involves using containers, like vectors and maps, which are built into STL. (Besides the standard built-in containers, the author also highlights recent additions to STL like B-trees, which are available as extensions from other vendors.) You'll learn the best ways to allocate, add, change, and delete items inside containers, including associative containers like maps. You'll also learn to avoid common pitfalls, which can result in writing code that is slow or just plain wrong.

Other areas covered in Effective STL cover getting the most out of the 100-plus STL algorithms that are bundled with this library. Meyers shows you how to choose the correct algorithm for sorting and other functions. (Even advanced developers will learn something here.) Sections on using function objects (called functors) round out the text. Meyers shows you when these classes make sense and the best ways to implement them. Besides specific tips, you'll get plenty of general programming advice. A useful appendix shows the limitations of STL as implemented in Microsoft Visual C++ 6.0 and how to overcome them.

Overall, Effective STL is a really invaluable source of programming expertise on an essential aspect of today's C++ for anyone who is using--or planning to use--STL in real production code. It is quite simply a must-have. --Richard Dragan

Topics covered:

  • Introduction to advanced Standard Template Library (STL) programming techniques
  • 50 tips and best practices for STL illustrated with sample tutorial code
  • Choosing containers
  • Efficient copying of elements inside containers
  • Removing, erasing, and cleaning up items from containers
  • Using custom allocators with STL containers
  • Thread safety with STL
  • Tips for programming with the STL vector and string classes (including reserving memory and calling legacy C/C++ code)
  • Tips for associative containers (including comparing items, sorted vectors, and non-standard enhancements to STL)
  • Tips for selecting and using STL iterator classes
  • STL algorithms (including sorting, removing, and comparing items)
  • Using functors with STL
  • General tips for STL programming (including advice for choosing algorithms and understanding compiler diagnostic messages)
  • String locales
  • Overcoming STL imitations in Microsoft Visual C++ 6.0

From the Back Cover

“This is Effective C++ volume three – it's really that good.”
– Herb Sutter, independent consultant and secretary of the ISO/ANSI C++ standards committee“There are very few books which all C++ programmers
must have. Add Effective STL to that list.”
– Thomas Becker, Senior Software Engineer, Zephyr Associates, Inc., and columnist,
C/C++ Users Journal

C++'s Standard Template Library is revolutionary, but learning to use it well has always been a challenge. Until now. In this book, best-selling author Scott Meyers (, and ) reveals the critical rules of thumb employed by the experts – the things they almost always do or almost always avoid doing – to get the most out of the library.

Other books describe what's in the STL. Effective STL shows you how to use it. Each of the book's 50 guidelines is backed by Meyers' legendary analysis and incisive examples, so you'll learn not only what to do, but also when to do it – and why.

Highlights of Effective STL include:

  • Advice on choosing among standard STL containers (like vector and list), nonstandard STL containers (like hash_set and hash_map), and non-STL containers (like bitset).
  • Techniques to maximize the efficiency of the STL and the programs that use it.
  • Insights into the behavior of iterators, function objects, and allocators, including things you should not do.
  • Guidance for the proper use of algorithms and member functions whose names are the same (e.g., find), but whose actions differ in subtle (but important) ways.
  • Discussions of potential portability problems, including straightforward ways to avoid them.

Like Meyers' previous books, Effective STL is filled with proven wisdom that comes only from experience. Its clear, concise, penetrating style makes it an essential resource for every STL programmer.

Product details

  • Publisher ‏ : ‎ Addison-Wesley Professional; 1st edition (June 6, 2001)
  • Language ‏ : ‎ English
  • Paperback ‏ : ‎ 288 pages
  • ISBN-10 ‏ : ‎ 0201749629
  • ISBN-13 ‏ : ‎ 978-0201749625
  • Item Weight ‏ : ‎ 1.29 pounds
  • Dimensions ‏ : ‎ 7.3 x 0.8 x 9.1 inches
  • Customer Reviews:
    4.5 4.5 out of 5 stars 167 ratings

About the author

Follow authors to get new release updates, plus improved recommendations.
Scott Meyers
Brief content visible, double tap to read full content.
Full content visible, double tap to read brief content.

For more than 20 years, Scott Meyers' Effective C++ books (Effective C++, Effective Modern C++, Effective STL, and More Effective C++) have set the bar for C++ programming guidance. His clear, engaging explanations of complex technical material have earned him a worldwide following, keeping him in demand as a trainer, consultant, and conference presenter. He has a Ph.D. in Computer Science from Brown University.

Customer reviews

4.5 out of 5 stars
167 global ratings

Top reviews from the United States

Reviewed in the United States on April 11, 2011
"Effective STL" is the final installment of Scott Meyers' "Effective" trilogy. While the first two volumes ("Effective C++" and "More Effective C++") discussed general tips on C++, "Effective STL" focuses exclusively on the STL, which is taken to mean the parts of the C++ standard library that work with iterators. It goes without saying that this book should be read after "Effective C++, Third Edition". One could probably get away with skipping over "More Effective C++", thus going directly from "Effective C++" to "Effective STL".

The Good: in typical Meyers style, the writing is generally relaxed and even pleasant, e.g. "This works, but only if you're not terribly picky about what you mean by 'works'." (Item 7). Like in "Effective C++" (but in contradistinction to "More Effective C++") most Items are quite short and therefore easily digestible. Similarly, in this volume, too, Meyers often reiterates the main point of each Item before concluding: this sometimes feels needlessly repetitive, but is mostly great for driving home the essential issues. As in the earlier volumes, things are for the most part organized intuitively. Meyers has a knack for pedagogy and thus for different ways of getting the message across, cf. the few tables that are included in the book, most notably the one on search options in Item 45. The author's organizational prowess is also evidenced by the numerous cross-references and the list of performance-related Items at the end of the Introduction. Moving on to the specifics of the material covered in this volume: Meyers is at his best when addressing a host of topics that elsewhere are often jumbled together. The finest examples of this skill are Items 31, 41, and 45, which deal with sorting options, function adapters, and search algorithms, respectively. Meyers manages to methodically explain the commonalities and distinctions between related concepts. The overwhelming majority of the topics covered in this volume have to do with real-life programming in C++, e.g. how to pass vector and string data to legacy APIs (Item 16). In this vein, some of the Items in "Effective STL" can safely be said to constitute required reading, especially the following on: a) range member functions versus their single-element counterparts (Item 5), b) C++'s most vexing parse (Item 6), c) the swap trick used to eliminate excess capacity (Item 17), d) the erase-remove idiom that allows one to really remove elements from a container (Item 32), e) the superiority of algorithm calls in comparison with hand-written loops (Item 43), and f) the advantages of container member functions over STL algorithms with the same name (Item 44). Other Items feel like digressions (e.g. Item 10 on allocators, Item 18 on vector of bools, or Item 23 on replacing associative containers with sorted vectors) though that doesn't make them any less interesting.

The Bad: this volume is not introductory but it isn't a very good reference either. For example, in the early Items Meyers talks about list's splice member functions matter-of-factly. Of course, "Effective C++" and "More Effective C++" are also not introductory or reference works, but there's a major difference: in those books when Meyers discusses a new construct he first explains it briefly. In "Effective STL", on the other hand, he often implicitly assumes the reader will go look stuff up in something like Josuttis' book "The C++ Standard Library" (regarding which Meyers writes: "[e]very C++ programmer should have ready access to a copy"). Obviously, a short hints-and-tips type book cannot contain everything, but the reader's life would have been made much easier had Meyers simply included a few reference tables (containing function signatures) in an Appendix. Moreover, what the Appendices do include is not uniformly interesting: Appendix B addresses developers using Microsoft Visual C++ versions 4-6 and is therefore largely irrelevant today. Another point where "Effective STL" diverges slightly from the earlier volumes' practices is cross-referencing. Meyers mentions other Items extensively in those books, too, but here he's gone overboard: for example, by the time he introduces unary_function and binary_function in Item 40, he has referred to them 10 times already, which probably means that they should have been covered (way) earlier. On a different note, given the non-exhaustive nature of the book, there's important stuff that's missing, e.g. there's absolutely no mention of the at() member function of vectors, deques, and strings. Also, a few of the examples feel somewhat contrived (e.g. anyone paying attention up to that point can tell that the initially proposed solution in Item 42 is obviously unnecessary), though this is more the exception than the rule. Finally, the book's age is starting to show: "Effective STL" was published in 2001 so (despite being more up to date than "More Effective C++") a number of things would be done differently today. For example, Meyers uses for_each in many code snippets, most of which would look much cleaner using lambdas.

In a nutshell, I would say that this book is not as indispensable as "Effective C++, Third Edition", but is probably more useful than "More Effective C++". Meyers is a talented author and instructor, so all three volumes are worth reading. Were "Effective STL" to be re-written today (using C++11 and its library) the result would certainly be more interesting, but the advice contained in this book is solid, nonetheless. Overall, four and a half stars.

Alex Gezerlis
12 people found this helpful
Report
Reviewed in the United States on August 13, 2004
I'm a professional software engineer. I write code all day long and have lots of experience with C++, but I hadn't used STL much until recently. If you're in a similar situation--decent C++ knowledge but not an STL expert--this book is for you. I haven't even read the whole thing yet, and already I am using patterns from the book to write more effective code.

Before I started this book, I thought STL was kind of neat. It had some useful containers. It was nice to be able to use a list or map or string class that had already been tested.

Boy, was I underestimating the power of STL. This book has made me a big STL fan, but I'm not reviewing the STL now so I'll leave that topic alone... Thanks to Scott Meyers, I have a much better grasp of the capabilities and limitations of STL. I can use it to do a lot more. I write more concise code that's easier to read and debug. I make better choices about which containers to use. I recognize situations where I can use an STL algorithm instead of many lines of my own code.

In short, I look at the STL code I wrote before and laugh... I mean, it all works, but the Meyers book has taken my use of (and appreciation for) the STL to a whole new level. I recommend this book for any C++ developer who isn't already an STL expert.

An update, 2 years after the above text was written: I still recommend this book to people and still think it's the best STL book I've read.
26 people found this helpful
Report
Reviewed in the United States on September 9, 2005
I bought this book in a hurry for the purpose of using STL functions for my programming project. It does have some very good and useful advises and tips for dealing with various problems, and is not assuming the reader of it is too much of an entry level programmer.

However, my biggest complaint of it is the print layout, including its font/size/color, the font is too heavy and dark (almost all Bold like) and make it harder to read through, especially some C++ code section which should definitely be printed in smaller, lighter and program code like style which is unfortunately not.
2 people found this helpful
Report
Reviewed in the United States on March 6, 2014
I was brought up on STL with C++, and can't imagine the language without it. This book, however, opened my eyes to many of the strengths, weaknesses, and issues of the Standard Template Library. It tells the reader why to use a deque of booleans instead of vector. More importantly, it provides warnings about features to avoid, as well as how to make better use of this now standard library. Open source software contributors should also check this book out to understand best practices. There's a temptation in C++ to treat iterators like pointers, but Scott Meyers explains clearly why you shouldn't. He briefly discusses the 100 algorithms that are offered in STL, and several key Items, like "Item 30: Make sure destination ranges are big enough" and "Item 32: Follow remove-like algorithms by erase if you really want to remove something."

Readers even get some of the back story on the decisions that went into the development of STL and why they made some of the compromises that they did. The book is so clear, so lucid, and so interesting that even the novice C++ programmer will enjoy its prose. It is thoroughly informative even for programmers at all levels of experience with C++.
3 people found this helpful
Report

Top reviews from other countries

Translate all reviews to English
Client d'Amazon
5.0 out of 5 stars Really helpfull
Reviewed in France on November 25, 2019
I read this book and I think I can use it to improve my knowledges about STL
hugh
5.0 out of 5 stars Five Stars
Reviewed in Canada on May 24, 2017
I love it.
Amazon Customer
5.0 out of 5 stars Five Stars
Reviewed in India on November 2, 2016
Good Book
v.tran
5.0 out of 5 stars kann nicht besser sein
Reviewed in Germany on June 5, 2016
Ich hoffe es gibt bei allen Programmiersprachen ein so gutes Buch wie dieses. Bist Du Anfänger bei Programmierung? Dann bleib weg von dem und schau mal TCPL von Stroustrup an. Hast Du schon Erfahrung mit (am besten) verschiedenen Programmiersprachen, dann alle Bücher der Serie "Effective ..." von Meyers sind "Must Read", damit man wirklich richtig mit C++ arbeiten kann.

Leider, dass so ein gutes Buch nicht in gebundener Ausgabe publiziert wurde.
Steve
5.0 out of 5 stars Must have
Reviewed in the United Kingdom on June 3, 2012
I've now bought all of Scott Meyers' books, and if you have anything to do with C++ then I strongly recommend you do the same.

Frankly, they are a must-have collection that describe the best way of writing C++ and using the STL. If only they'd been available all those years ago when I first learnt C++ , then I could have saved myself much grief!

Scott's style is very informal and readable. Not only does he make difficult topics easy to understand, but he does so in an interesting and accessible manner.

It's worth pointing out that these books are not intended for learning C++ from scratch, rather they are intended to show you the best ways of applying your knowledge in solving many common programming problems. This STL book focuses on getting the most out of the standard library functions, and avoiding the many pitfalls and misconceptions. All the items are explained with useful code examples (some of which may well find their way into your own libraries of most used functions/templates). Reading this book, not only do you fully understand the STL functions and how to use them properly, but also when to use them and why one may be much better suited to your particular task than the other (similar) functions.

In short, buy it (and his companion books)!