
Untitled
By: a guest on
Aug 7th, 2012 | syntax:
None | size: 0.57 KB | hits: 6 | expires: Never
Why does inlining template specializations help and should I do it?
template <typename foo>
void f(foo p)
{
std::cout << "f one" << std::endl;
}
template <>
void f<int>(int p)
{
std::cout << "f two" << std::endl;
}
templateordering.obj : error LNK2005: "void __cdecl f<int>(int)" (??$f@H@@YAXH@Z) already defined in othertu.obj
template <>
inline void f<int>(int p)
{
std::cout << "f two" << std::endl;
}
template<> void f<int>(int p);
template <>
void f<int>(int p);
template <>
static void f<int>(int p)
{
std::cout << "f two" << std::endl;
}