Boost logo

Boost Users :

Subject: Re: [Boost-users] Using boost with explicit template instance
From: Chris Cleeland (chris.cleeland_at_[hidden])
Date: 2011-10-11 11:00:55


On Tue, Oct 11, 2011 at 8:13 AM, Ranadheer <p_ranadheer_at_[hidden]> wrote:
> The only advantage of using explicit template instantiation is that it seems
> like it would result in least compilation time and small object sizes
> (http://download.oracle.com/docs/cd/E19205-01/819-5267/bkagp/index.html). As
> a note, I don't know how good this is from relying on compiler to
> instantiate.
>
> As I said, I also understand that it doesn't make sense to instantiate all
> internal boost templates explicitly but we are planning to use this library
> in a legacy binary which is using "--instances=explicit" option. So, just
> wanted to confirm before I remove "--instances=explicit" and resolve the
> other issues which might be resulting of this removal.

The two justifiable reasons for explicit instantiation I have
encountered in the past 15+ years of C++ development are:

1. a library uses templates in its implementation and needs to provide
instantiations that the compiler wouldn't implicitly determine but
that, as a provider of the library, you know will be required by code
linking the library

2. the implicit instantiation engine sucks

Fortunately, #2 isn't often the case any more. And #1 doesn't really
justify demanding that the compiler ONLY do explicit instantiation,
because it's entirely okay (in my experience) to explicitly
instantiate templates as one would do in #1 and still let the compiler
do implicit instantiation for the general case.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net