Subject: Re: [boost] Interesting variadic template trick
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2013-11-18 06:49:26
On Mon, Nov 18, 2013 at 3:27 PM, Jonathan Wakely
> On 18 November 2013 10:07, Andrey Semashev wrote:
>> I probably didn't express myself clear. I was asking whether the
>> compiler is able to optimize N identical instantiations to the cost of
>> just one.
> There aren't N identical instantiations, there can only be two.
> Instantiating a given template specialization is only done once per
> translation unit. When it's already instantiated there's nothing to
> "optimize", the compiler just refers to the existing instantiation and
> uses it, similar to how it would use a non-template class.
> Across multiple translation units there might be duplicate
> instantiations that can be discarded, but that's dealt with by the
> linker, in the same way as duplicate copies of inline functions,
> vtables and RTTI info.
You're right, of course. Thanks.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk