I know this question has been asked numerous times, but referring to the answer to this question: How can I specialize a template member function for std::vector<T>
if I try a simple example of this using GCC9 it simply does not work, and I cant understand why not. Am I missing something here?
#include <vector>
#include <stdio.h>
template<typename T>
std::vector<T> foo( const std::vector<T> & )
{
printf( "vector!\n" );
return std::vector<T>();
}
template<typename T>
T foo( const T & )
{
printf( "non vector!\n" );
return T();
}
int main()
{
foo<int>( *( int * ) nullptr);
foo<std::vector<int>>( *( std::vector<int> * ) nullptr);
}
Outputs:
non vector!
non vector!