C/C++
empty.txt
Associated article: The Empty Member C++ Optimization
Tags: C/C++
Published source code accompanying the article by Nathan Myers in which he asks the question "Although the STL is flexible, does it use too much memory?" Nathan shows how the STL--and you--can use empty subobjects without bloating your data requirements.
_The Empty Member C++ Optimization_
by Nathan Myers
Listing One
template <class T>
class allocator { // an empty class
static T* allocate(size_t n)
{ return (T*) ::operator new(n * sizeof T); }
. . .
};
Listing Two
template <class T, class ...


