问题
I am using quite a few containers of the form
boost::bimap<boost::bimaps::multiset_of<std::string>, boost::bimaps::set_of<AnEnum> >
I am defining them in a header file that is included in quite a few cpp files (This is after I limited the exposure of the header file as much as possible). The .a files being created in the debug build runs to above 1 GB (resulting in compilation stopping midway due to 'no space on device' error and naturally the compile time has increased exponentially.
The compiler being used is gcc 4.8.1. Just wanted to know if anyone has encountered this problem with boost::bimap and what they did to resolve this issue
回答1:
I is very likely that each time you use such a bimap
in a different file, it is specialized leading to huge code duplication. If you are using c++11
then you should declare them as extern template
, And specialize it in only one file. See using extern template (C++11)
来源:https://stackoverflow.com/questions/22166315/boost-bimap-takes-too-much-memory-in-debug-build