Search code examples
c++template-function

inline template function?


Do I need inline template functions if they are included in several cpp files? Thanks.

template<bool> inline QString GetText();
template<> inline QString GetText<true>() {return "true";}
template<> inline QString GetText<false>() {return "false";}

Solution

  • You do, because those are full function specializations, and therefore subject to the one-definition rule just like normal functions.