Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Is this standar...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 9590 of 9823
Post > Topic >>

Is this standard, or Visual C++ bug ?

by rolkA <samy.rolka@[EMAIL PROTECTED] > May 11, 2008 at 04:41 PM

Ok so consider this code :

namespace Bar
{
	template <class T2>
	T2 f()
	{
		return T2(0);
	}
}

template <class T>
void Foo(float y = Bar::f<float>())
{
}

int main()
{
	Foo<int>(); // C2783: 'T2 Bar::f(void)' : could not deduce template
argument for 'T2'
	return 0;
}

It does not compile with Visual C++ 2005 and 2008, but G++ has no
problem with it.
But now, if I remove the template from Foo, it works :

namespace Bar
{
	template <class T2>
	T2 f()
	{
		return T2(0);
	}
};


void Foo(float y = Bar::f<float>())
{
}

int main()
{
	Foo<int>(); // no problem
	return 0;
}

And if f is not in a namespace, it works too :

template <class T2>
T2 f()
{
	return T2(0);
}


template <class T>
void Foo(float y = f<float>())
{
}

int main()
{
	Foo<int>(); // no problem
	return 0;
}

Any idea ? Thank you.

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 4 Posts in Topic:
Is this standard, or Visual C++ bug ?
rolkA <samy.rolka@[EMA  2008-05-11 16:41:13 
Re: Is this standard, or Visual C++ bug ?
=?ISO-8859-1?Q?Daniel_Kr=  2008-05-12 09:43:30 
Re: Is this standard, or Visual C++ bug ?
rolkA <samy.rolka@[EMA  2008-05-14 17:52:45 
Re: Is this standard, or Visual C++ bug ?
Andrey Tarasevich <and  2008-05-14 17:52:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 1:43:08 CDT 2008.