Boost Bimap takes too much memory in debug build

2019-07-22 07:55发布

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条回答
我想做一个坏孩纸
2楼-- · 2019-07-22 08:35

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)

查看更多
登录 后发表回答