July From the Pages Columns
TRAPS & PITFALLS
Conversions and Overloading
Andrew Koenig
The C++ rules for overloading and conversions work well most of the time, but they do not solve all problems all the time. The troublesome cases are typically those in which unexpected built-in conversions are possible. Koenig presents two examples where such conversions cause problems, and offers suggestions on how to avoid them.
GUEST COLUMN
Patterns and Trees: Separating Knowledge
Ruurd F. Pels
Pels applies the knowledge of patterns successfully to divide separate pieces of knowledge about the world we model. He uses the Visitor pattern to mediate between the world of TreeView and an internal Composite tree, and successfully separates the knowledge about tree traversal from the tree itself.
FROM MECHANISM TO METHOD
Valued Conversions
Kevlin Henney
Understanding a mechanism does not necessarily impart wisdom as to its best use. The same can be said of C++'s many features. Henney explains that knowledge of denomination does not necessarily settle design issues. Associated principles and practices that conceptually organize features into a more coherent whole can assist the programmer.
COMMON KNOWLEDGE
Elemental Base Idioms
Stephen C. Dewhurst
A programming language such as C++ is sufficiently complex that the community of C++ programmers has created a body of standard usage and idiom. The C++ language allows much flexibility in how it may be used, but idiomatic usage of language features allows efficient and clear communication of a design. Dewhurst addresses a small subset of C++ programming idioms concerned with the design of base class interfaces.
THE STANDARD LIBRARIAN
Algorithms and Containers
Matt Austern
Austern shows three code samples that illustrate some of the most common mistakes made when using C++ library containers, iterators, and algorithms, and shows how the mistakes all involve the difference between applying an algorithm to a container and applying an algorithm to the range of elements in a container. Further, he discusses how container_traits will be an important tool for writing container-based algorithms.
(B)LEADING EDGE
Simple Memory Management Classes
Jack W. Reeves
A nice thing about the Standard library containers is that you can have multiple iterators in a container, and the iterators in the node-based containers are guaranteed to remain valid as long as the element referenced is in the container. Reeves explains that these iterators have many of the same useful properties as ordinary pointers, but because they are attached to containers such as map, set, or list, they can be manipulated in much more useful ways.