Reputation: 24719
Consider the following overloaded functions:
template <class T>
void foo(const T& v)
{
std::cout << "Generic version" << std::endl;
}
void foo(std::pair<const void*, std::size_t> p)
{
std::cout << "Pair version" << std::endl;
}
Below, I expect the second overload (the one that takes an std::pair
) to be called:
int main()
{
const void* buf = 0;
std::size_t sz = 0;
foo(std::make_pair(buf, sz));
}
However, this code in fact calls the generic version. Why doesn't it bind to the overload that specifically takes an std::pair
? Is this a compiler bug? I'm using a pretty old compiler, GCC 4.1.2
Upvotes: 1
Views: 83
Reputation: 5721
Try
template <>
void foo(const std::pair<const void*, std::size_t>& p)
{
...
}
Upvotes: 3