O'Reilly logo

Professional C++, Second Edition by Scott J. Kleper, Nicholas A. Solter, Marc Gregoire

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 17

Customizing and Extending the STL

WHAT’S IN THIS CHAPTER?

  • What allocators are
  • What iterator adapters are
  • How to extend the STL
    • How to write your own algorithms
    • How to write your own containers
    • How to write your own iterators

The previous chapters show that the STL is a powerful general-purpose collection of containers and algorithms. The information covered so far should be sufficient for most applications. However, those chapters show only the basic functionality of the library. The STL can be customized and extended however you like. For example, you can apply iterators to input and output streams; write your own containers, algorithms, and iterators; and even specify your own memory allocation schemes for containers to use. This chapter provides a taste of these advanced features, primarily through the development of a new STL container: the hashmap.

cross.gif

This chapter is not for the faint of heart! The contents delve into some of the most complicated and syntactically confusing areas of the C++ language. If you’re happy with the basic STL containers and algorithms from the previous chapters, you can skip this one. However, if you really want to understand the STL, not just use it, give this chapter a chance. You should be comfortable with the operator overloading material of Chapter 18, and because this chapter uses templates extensively, you should also be comfortable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required