template< class T >
class Foo {
public:
Foo( T t ) { }
};
int main () {
int i = 0;
Foo f( i );
}
In the above code, the compiler complains that template arguments are missing before 'f'. I understand that deducing template arguments for a class from the arguments to the constructor is not part of the standard, but my question is why? Doesn't the compiler have all the information it needs to implicitly instantiate Foo<int>
and call its constructor?
Edited to make it clear that I'm calling the constructor with an int
(as opposed to a short
, long
, void*
, etc.)