Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Explicit Template Instantiation Declaration doesn't avoid code generation.

$
0
0

Hello,

Here is a proof of concept :

template <typename T>
struct zoo
{
    T a;
    T foo() { return 2 * a; } // at least one function so zoo requires some code generation.
                              // -> explicit decl are more likely to require an explicit def.
};

extern template zoo<int>;

int main()
{
    zoo<int> a;
    return a.foo();
}

This single source file program compiles and links without error with "Intel C++ 15.0" on Windows, while in my understanding it would be looking for a missing explicit definition.

So does it mean compilation isn't faster using the new C++11's "extern template" method ?

And how can I know I'm not missing any explicit definitions in my library except by trying to compile with a conformant compiler ?

Thank you in advance.


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>