Previous reading guide     Next reading guide

AP Reading guide - Lecture 6

This is a reading guide to Part III and IV (chapter 28 - 33)) of The C++ Prog. Lang. (4. edition)

Chapter 28. This chapter is warmly recommended. I find it very interesting! The introduction in 28.1 discusses generic programming in contrast to metaprogramming. This is fairly interesting and informative at a high level. Section 28.2 shows how to write type functions: functions that return types or takes a type as a (template) parameter. std::conditional is used a lot in this section. Type functions makes it possible to calculate types at compile time. Boolean valued type functions are type predicates (28.2.2). C++ supports a lot of type predicates in <type_traits>, see 35.4.1 page 1018. Metaprogramming involves both selection and iteration (28.3). Type selection is fairly simple to define with template specialization (28.3.1.1). Iteration is dealt with by recursion. Section 28.4 is about conditional definitions: A technique for only including definitions in certain situations (dealt with at compile time, of course). Section 28.5 is a relative long example: Tuples up to four elements (of different types, if necessary). The generalization of this requires variadic templates (28.6) which are easy to use, but quite complex to program (see 28.6.4, where the general Tuple is discussed). Section 28.7 is another example: doubles attached to a unit (meter, kilogram, second).

Chapter 30 gives an overview of the C++ standard library. Notice 30.1.3 which describes the style of library description in the book. Section 30.2 goes through all header files in the physical organization of the library. Section 30.3 is a short section about library support for the language as such. Section 30.4 is long section about error handling (exception support). I soon stopped reading all these details, I must admit. Feel free to do the same, unless exception handling is your favorite subject. If you follow this advice, chapter 30 is an easy read.

Chapter 31 gives an overview of the STL Containers. Read 31.2 for a basic overview, including some insight into the representation of containers. Section 31.3 discusses the container operations, not least time complexity guarantees. The tables shown in the rest of 31.3 are useful supplementary (and compact) library info, relative to www.cplusplus.com. (Be sure to read 30.1.3 for an explanation of the style of description). Section 31.4 goes in more details, first with vectors. You should also notice the std::array type (see 34.2.1 for additional details) in contrast to std::vector. Depending on your needs and interest, you may stop reading when you got enough details. 31.5 is a relatively short section on contain adaptors (stack, queue, ...) Be sure to grab the adaptor idea. 31.6 (Advice) is good!

Chapter 32: Algoritms. Section 32.2 explains how sequences are handled with use of iterators. 32.3 is about policy arguments - compile time parametrization with bundles of functions. The rest of the chapter is a an overview of all the C++ algorithms. I recommend that you familarize yourself with some of them, for instance those in 32.4. It is rather tedious to read through all the details of this chapter. You should use it for reference purposes.

Chapter 33: STL Iterators. You should read 33.1 in order to understand interator basics, and in order to obtain an overview of them many different kind of iterators supported by the C++ standard library. In section 33.2, reverse iterators and insert iterators are noteworthy. I also recommend 33.4 (a short section) about function objects.

Previous reading guide     Next reading guide

/KN