The only portable way of using templates at the moment is to implement them in header files by using inline functions.
Why is that?
Because when compiler instantiate the template, it need to access to the implementation of the methods. If it’s not together with it’s declaration, the compiler doesn’t know how to instantiate it. For example:
template <typename T>
and when you declare:
The compiler will generate code like this:
There are other ways to achieve this, for example implement it in some
.tpp files and include those files after their declaration, as long as compiler can access to the definition of that template.