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.
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 ...