I have this code:
#include <iostream>
struct A
{
template<typename T> bool isImplemented()
{
std::cout << "Not Implemented" << std::endl;
return false;
}
};
template<> inline bool A::isImplemented<int>()
{
std::cout << "int Implemented" << std::endl;
return true;
}
I can understand why the template specialization needs the inline, in order to prevent the ODR to be violated the inline will merge the translation table avoiding a conflict.
But, why I don`t need an inline on the isImplemented inside the struct A? Maybe that question can be extended to, why if the method is declared inside the struct/class on the header it does not need the inline? As I can understand, it would create the symbols on every object file (.o) that it is called, violating the ODR, why that does not happen?