|
Boost : |
Subject: Re: [boost] [testing] Add a tester with hidden visibility
From: John Maddock (jz.maddock_at_[hidden])
Date: 2015-05-07 13:38:18
> Up until C++ 11 I really would say "just don't do it". The compiler
> doesn't know not to instantiate dllexported templates and does so
> anyway, so compilation speedup is zero. Marking templates with
> dllexport means the linker must deal with a ton more symbols to match
> up and remove because they aren't hidden, so you lose on link times
> too. The only potential win is code size reduction, and given that
> most compilers compile template instantiations into two variants,
> inlined at point of use and extern, the latter rarely actually gets
> used and is therefore thrown away by the linker anyway, so the gains
> are usually not worth the significant added hassle and brittleness
> for most libraries with most reasonably sized templates.
>
> Since C++ 11 we have extern templates, and that finally makes
> dllexporting template instantiations useful. I can see very
> significant potential benefits especially to compile and link times
> there,
Boost.Regex has done this since day 1 for compilers that support it
(msvc and gcc). Compile time speedups are larger on msvc, but in both
cases well worth the effort. In fact it's one reason the library hasn't
gone header-only: it could probably be done, but compile times are just
*so* much faster when the template instances are in an external lib...
John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk