inline template function?

user1899020 picture user1899020 · Jul 16, 2013 · Viewed 34.4k times · Source

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";}

Answer

user541686 picture user541686 · Jul 16, 2013

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