![]() |
Home | Libraries | People | FAQ | More |
The flexible option specification mechanism used by Boost.Intrusive
for hooks and containers has a couple of downsides:
Boost.Intrusive
對鉤子和容器所使用的靈活的選項說明機制有兩個缺點:
#include <boost/intrusive/list.hpp> using namespace boost::intrusive; //Explicitly specify constant-time size and size type 顯式指定常量時間的 size 和 size 類型
typedef list<T, constant_time_size<true>, size_type<std::size_t> List1; //Implicitly specify constant-time size and size type 隱式指定常量時間的 size 和 size 類型
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:
為解決這些問題,Boost.Intrusive 提供了一些輔助元函數來縮短符號長度,並且在使用相同選項(不論顯式或隱式)時創建相同的類型。這樣也可以加快編譯的時間。所有的容器和鉤子都具有各自的
make_xxx 版本。前面所示的例子可以如下重寫,以獲得相同的 list 類型:
#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 顯式指定常量時間的 size 和 size 類型
typedef make_list<T, constant_time_size<true>, size_type<std::size_t>::type List1; //Implicitly specify constant-time size and size type 隱式指定常量時間的 size 和 size 類型
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.
這樣所產生的符號長度和編譯時間通常都更短,目標文件和調試文件也更小。如果你關注文件的大小和編譯時間,這是你最好的選擇。