Enforcing Compile-time Constraints
eneric containers and algorithms often impose certain restrictions on the objects that they manipulate. For example, the std::sort() algorithm requires that the elements on which it operates shall define the
eneric containers and algorithms often impose certain restrictions on the objects that they manipulate. For example, the std::sort() algorithm requires that the elements on which it operates shall define the
n a previous column, I discussed the Standard Library’s map associative container. But this was only one half the story. The Standard Library also defines a multimap container, which is
elational databases, scientific apps, and Web-based systems often need a vector-like container whose index can be of any type, not necessarily int. Such containers are known as associative containers or
he C++ standards committee is now working on updates and enhancements to the Standard Library. Tuple types are one of the recent additions to the standard. A tupleis a fixed
he C++ preprocessor may seem like a prehistoric relic that has no place in state-of-the-art C++ projects, but this isn’t really so. Although every beginner nowadays knows how to use
base class provides an interface that is inherited by derived classes. However, in some cases you need to extend, or even alter, the base class’s interface in a derived class.
ertain objects must be converted to a low-level representation and vice versa. Programmers using std::string objects, for instance, have to convert them to bare char pointers, as in the following
s we all know, premature optimization is considered evil as it often entails eventually useless design complications and portability compromises. However, this doesn’t mean that healthy programming habits should be