| Home | Libraries | People | FAQ | More

## 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:

- If a user specifies the same options in different order or specifies some options and leaves the rest as defaults, the type of the created container/hook will be different. Sometimes this is annoying, because two programmers specifying the same options might end up with incompatible types. For example, the following two lists, although using the same options, do not have the same type:

    #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;

- Option specifiers lead to long template symbols for classes and functions. Option specifiers themselves are verbose and without variadic templates, several default template parameters are assigned for non-specified options. Object and debugging information files can grow and compilation times may suffer if long names are produced.

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.