1

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

john_zac
  • 1,241
  • 2
  • 11
  • 16

1 Answers1

2

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)

Community
  • 1
  • 1
hivert
  • 10,579
  • 3
  • 31
  • 56
  • Sorry for the late reply. Since there were lot of such maps, it took me time to make corrections and verify. But yes this method reduces the size significantly. Having said that I strongly recommend against using boost bimap unless absolutely required. In debug build my final application had a size of 110 MB with bimap and 35 MB without. In release it had a size of 33 vs 8. And this is after I was able to create the binary because I used the above method. – john_zac Mar 10 '14 at 04:42