Current area: HOME -> C / C++ -> Standard Template Library Articles
Standard Template Library
C++ header dependency tricks
Keeping header file dependencies to a minimum in C++ is always a good idea. Theres a great book on the subject. John Lakoss Large Scale C++ Design , but theres plenty of little tricks that arent mentioned. In this article I discuss a cool trick Ive discovered in reducing dependencies, particularly useful for STL headers.
Clone Smart Pointer (clone_ptr)
The clone_ptr class is a smart pointer that can clone itself without requiring the base class to have a clone method. It can clone itself to the type pass to the constructor. The constructor for the clone_ptr is a template method, which is able to store type information for later usage when cloning the pointer.
Enforcing Compile-time Constraints
Implementing some constraints require too much elbow grease. Wouldn't it be great to find a way to generically implement those more abstract constraints? The following solution shows you how to do just that.
Into the STL distance function
The purpose of this article is to demonstrate the basic concepts of template programming (such as: tags and traits classes). In this article, I will implement some functionality of the "distance" STL function. By dealing with the various problems emerging, the basic concepts can become clearer.
Manage Your STL Container's Storage with Self-swapping Idioms
How do you trim a container whose capacity is larger than necessary? How do you force a container to destroy its elements and set its capacity to 0? Find out how to regulate an STL container's storage manually.
Software Development Targets corporate developers and technical managers working at mainly mid- to large-size companies with sizable development staffs....
subscribe now