3,973 questions
template <typename T>
void swap_bytes(T& a, T& b)
;
template <>
void swap_bytes(int& a, int& b)
{
std::swap(a, b);
}
template <>
void swap_bytes(float& a, float& b)
{
std::swap(a, b);
}
int main()
{
int a{ 3 }, b{ 4 };
swap_bytes(a, b);
char c1{ 'q' }, c2{ 'r' };
swap_bytes(c1, c2); // fatal error LNK1120
return 0;
}
I found it, just declare the template, not implement it.