
on Thu Apr 05 2012, Steven Watanabe
AMDG
On 04/04/2012 06:07 PM, Dave Abrahams wrote:
Plus, the way the language is defined, ordering is very important. There's a point of definition and various points of instantiation... particular lookups are done in those locations, and the symbol table has to be right in each case, at least with respect to the symbols used in the template. I doubt it's easy to unwind those dependencies.
But...
"If the function name is an unqualified id and the call ... would find a better match had the lookup within the associated namespaces considered all the function declarations with external linkage introduced within those namespaces in all translation units, not just considering those declarations found in the template declaration and template instantiation contexts, then the program has undefined behavior." (14.6.4.2)
"If a template, a member template, or a member of a class template is explicitly specialized, then the specialization shall be declared before the first use of that specialization that would cause an implicit instantiation to take place... no diagnostic is required" (14.7.3) (There is a similar clause for partial specialization)
In other words, it seems to me that in most cases where delaying the point of instantiation would change the behavior it is either undefined behavior or ill-formed, no diagnostic required.
But "most cases" is not enough. If you can show that's true in *all* cases, there may be a case for parallel template instantiation. -- Dave Abrahams BoostPro Computing http://www.boostpro.com