I have just a simple question, check this code please:
template < typename A >
void foo( A a )
{ cout<<"1\n"; };
template< >
void foo<float>( float a )
{ cout<<"2\n"; }
void foo( float a )
{ cout<<"3\n"; }
int main()
{
foo<float>( 1.0f );
}
Compiled with g++ 4.7.2 works of course, but what is not clear to me is why the output is "2" instead of "3".
As far as I remember a non template function shall be always preferred towards a template one, so why is called the specialized foo?
Thanks