Boost logo

Boost :

Subject: [boost] Making use of extern template
From: Jens Auer (jensa_at_[hidden])
Date: 2012-09-10 04:22:36


Hi,

I tried to use C++11 extern template mechanism to reduce the turn-around time for our main project, but it turns out that the way people write template code in libraries is not suited well for that purpose. I tried to explicitly instantiate the template base class of boost::posix_time_ptime, date_time::base_time<ptime, posix_time_system>, because ptime is a value class which is used quite often in our project. The base class is then instantiated in every translation unit and later removed by the linker (we use MS Visual C++ 2010. The linker is single threaded and dead slow). The problem with extern template and the boost library is that inline template code is still instantiated in every translation unit even when using extern template, so it basically has no effect with the current boost code:
$14.7.2.10: "Except for
inline functions and class template specializations, explicit
instantiation declarations have the effect of suppressing the implicit
instantiation of the entity to which they refer."

I would like to have a discussion of how boost could support extern template to reduce built times, maybe by changing the coding style to not write template code inline and use extern template in the library to automatically suppress instantiation of library instantiations such as the base class of ptime.

Best regards,
  Jens


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk