[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Bug c++/5458] address of overloaded template function as argument for template




------- Comment #15 from joseph dot h dot garvin at gmail dot com  2010-01-21 18:38 -------
I'm not sure what the standard says, but conceptually, if you only provide a
template generic template foo, with no non-templated foo defined, then
instantiations of foo are *never* 'overloaded.' If I have:

template<int n>
void foo() {}

Then foo<3> is a distinct function from foo<2>. It doesn't make sense to refer
to foo as overloaded (unless there is also a non-templated foo defined). foo<3>
has a single unique address, there is no ambiguity. Automatically considering
it an overloaded function (as I suspect GCC must be doing internally) leads to
a confusing error when compiling this snippet:

#include <iostream>

template<int n>
void foo() {}

int main()
{
        &foo;
}

You get the same error about not being able to resolve foo because it's
overloaded. But foo isn't a function at this point. It's a template. And no
template parameters have been filled in. I should get an error about expecting
angle brackets.


-- 

joseph dot h dot garvin at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |joseph dot h dot garvin at
                   |                            |gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5458

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Reply to: