I mean to write a templated function, which should be available for a somewhat large number of typename
s.
So, I mean to avoid needing explicit instantiation.
In this case, is it mandatory to write the definition of the function in the header?
Is there any other way? (It would be used in several places, so the definition cannot be written in any single source file).
PS: Why can templates only be implemented in the header file? refers to templated classes. Even though it may be reasonable to think that the same applies to functions, perhaps sometimes, it may not be the case. Thus, the link does not answer this specific question.