devxlogo

C C++

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

Preserve Code Safety with Conversion Operators

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

Optimize Your Member Layout

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