Are methods of templated classes implied inline linkage (not talking about the inline optimization), or is it just templated methods which are?
// A.h
template<typename T>
class A
{
public:
void func1(); // #1
virtual void func2(); // #2
template<typename T2> void func3(); // #3
};
template<typename T>
void A<T>::func1(){} // #1
template<typename T>
void A<T>::func2(){} // #2
template<typename T>
template<typename T2>
void A<T>::func3<T2>(){} // #3
Are all the above cases inline [linkage]? (Should I explicitly write inline for any of them)?
Template functions and member functions of template classes are implicitly inline1 if they are implicitly instantiated, but beware template specializations are not.
By lack of a better quote:
1 Only in the sense that multiple definitions are allowed for them, but not for optimization purpopses. You can manually mark them
inlineas a hint for the optimizer.See
[basic.def.odr]/13.4– the templates by themselves are excempt from ODR, not because they’re implicitlyinline.