partial ordering of function templates

Gabriel Dos Reis gdr@codesourcery.com
Wed Jan 10 11:25:00 GMT 2001


Nathan Sidwell <nathan@codesourcery.com> writes:

| Hi,
| this question concerns 14.5.5.2, where I think gcc is erroneously rejecting
| a valid program -- but I'm not sure.
| 
| 	template <typename T> void Foo (T *); //a
| 	template <typename T> void Foo (T &); //b
| 
| 	void Baz (int *ptr)
| 	{
| 	  Foo (ptr);
| 	}
| 

[...]

| a: Foo (T *) -> Foo (X *), using Foo (T &) deduce T to be X *, deduction succeeds.
| b: Foo (T &) -> Foo (X &), using Foo (T *) deduction fails
| 
| so b is less specialized than a, and void Foo(T*) [with T = int] should
| be selected
| 
| Am I forgetting something?

No, your analysis is correct.

-- Gaby
CodeSourcery, LLC                       http://www.codesourcery.com


More information about the Gcc-bugs mailing list