我一直在思考以下问题。考虑两个文件:
A.cpp:
template<class T> void g(T) {}
inline void f() { g(1); }
B.cpp:
template<class T> void g(T) {}
void g(int) {}
inline void f() { g(1); }
没有void g(int) {}
这个程序是 100% 有效的。使用void g(int) {}
,g(1)
解析为 A.cpp 中的模板版本和 B.cpp 中的非模板。
该程序是否违反 ODR?为什么?