Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Obtaining the same types and reducing symbol length

The flexible option specification mechanism used by Boost.Intrusive for hooks and containers has a couple of downsides:

#include <boost/intrusive/list.hpp>

using namespace boost::intrusive;

//Explicitly specify constant-time size and size type
typedef list<T, constant_time_size<true>, size_type<std::size_t> List1;

//Implicitly specify constant-time size and size type
typedef list<T> List2;

To solve these issues Boost.Intrusive offers some helper metafunctions that reduce symbol lengths and create the same type if the same options (either explicitly or implicitly) are used. These also improve compilation times. All containers and hooks have their respective make_xxx versions. The previously shown example can be rewritten like this to obtain the same list type:

#include <boost/intrusive/list.hpp>

 using namespace boost::intrusive;

 #include <boost/intrusive/list.hpp>

 using namespace boost::intrusive;

 //Explicitly specify constant-time size and size type
 typedef make_list<T, constant_time_size<true>, size_type<std::size_t>::type List1;

 //Implicitly specify constant-time size and size type
 typedef make_list<T>::type List2;

Produced symbol lengths and compilation times will usually be shorter and object/debug files smaller. If you are concerned with file sizes and compilation times, this option is your best choice.


PrevUpHomeNext