samedi 15 juin 2019

Bundling a template function definition along with explicit instantiation

Are explicit instantiations of template functions allowed before the definition of the function, if a declaration occurs first?

E.g., is the following allowed:

// declaration
template <typename T>
void foo(T param);

// explicit instantiation
template void foo<int>(int);

// definition of primary template
template <typename T>
void foo(T param) {}

In general it seems to compile, but of course that is only a mild indication as to whether it is allowed or not.

Aucun commentaire:

Enregistrer un commentaire