Szablon func i nie szablonowe zamówienie połączenia
W Linuksie dostaję
template max() is called
Ale pod Windows dostaję
non-template max() is called
Czemu? W Linuksie używam gcc 4.5, aw systemie Windows używam VS2008.
#include <iostream>
#include <vector>
template < typename T >
inline void max( const int& a, const T& b )
{
std::cout << "template max() is called" << std::endl;
}
template < typename T >
inline void Imax( const int& a, const std::vector<T>& b)
{
max(a, b[0]);
}
inline void max( const int& a, const int& b )
{
std::cout << "non-template max() is called" << std::endl;
}
int main()
{
std::vector<int> v;
v.push_back(1);
Imax(1, v);
return 0;
}