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

Click here to view the latest version of this page.
PrevUpHomeNext

Obtaining the same types and reducing symbol length

The flexible option specification mechanism used by Boost.Intrusive for hooks and containers has also 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 that reduce symbol lengths and create the same type if the same options (either explicitly or implicitly) are used. This also improves compilation times. All containers and hooks have their respective make_xxx versions. Previous 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 are usually shorter and object/debug files are smaller. If you are a programmer concerned with file sizes and compilation times, this option is your choice.


PrevUpHomeNext