This code is well-formed. You only have to pay attention that the definition of the template is visible at the point of instantiation. To quote the standard, ยง 14.7.2.4:
The definition of a non-exported function template, a non-exported member function template, or a non-exported member function or static data member of a class template shall be present in every translation unit in which it is explicitly instantiated.