I've read about inlining template function specalizations here
Apart from requiring inline
keyword for instantation in a header which is logical, I can't find an answer whether it makes any difference to mark non specialized function templates as inline
in a header? be it member functions or just normal functions.
Please save from explaining how compiler knows better than programmer, the question is: does inline
keyword makes any sense for "unpacked" templates in a header?
are non specialized templates always inline since they are in a header? for bellow example pseudo code if we suppose Foo::bar
method can be either very lengthy or very short, does omitting inline
keyword or adding inline
keyword has any effect on acctual chance of inlining or not inlining expanded function by the compiler?
Here is an example for member function templates which reflects my code:
class Foo
{
public:
template<typename Type>
static Type bar();
};
Example non inline definition:
template<typename Type>
Type Foo::bar()
{
return Type();
}
Example inline definition:
template<typename Type>
inline Type Foo::bar()
{
return Type();
}
Is this inline
keyword above always useless, or it makes sense only if the function can be inlined by the compiler? are templates always inline in a header?