|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - partial ordering of template functions
#include <stdio.h>
template<class T>
struct A
{ };
struct B
{ };
template<class U, class T>
A<U> f(T t)
{
printf("1\n");
return A<U>();
}
template<class T>
A<B> f(T t)
// Error: 'f' previously declared as something else
// It was declared as: A<U>C func(T)
// It is now declared: A<B>C func(T)
{
printf("2\n");
return A<B>();
}
int main()
{
f(0);
// Error: ambiguous reference to symbol
f<int>(0);
// Error: ambiguous reference to symbol
return 0;
}
Extracted from Boost.Bind (to get adaptable function objects working).
gcc-3.0 chooses the second function for "f(0)" and the first one for
"f<int>(0)" and I guess that's what Boost.Bind expects.
bye, Christof
--
http://cmeerw.org JID: cmeerw jabber.at
mailto cmeerw at web.de
...and what have you contributed to the Net?
Dec 23 2002
I've fixed the first issue, 'Error: 'f' previously declared as something else'. But I think the other two should be ambiguous, I cannot find a rule that gives the results you are seeing from gcc-3.0. "Christof Meerwald" <cmeerw web.de> wrote in message news:au7ab9$67p$1 digitaldaemon.com... Dec 31 2002
On Tue, 31 Dec 2002 14:18:54 -0800, Walter wrote:I've fixed the first issue, 'Error: 'f' previously declared as something else'. But I think the other two should be ambiguous, I cannot find a rule that gives the results you are seeing from gcc-3.0. "Christof Meerwald" <cmeerw web.de> wrote in message news:au7ab9$67p$1 digitaldaemon.com... Dec 31 2002
All right. That does make some sense. I'll check it out. -Walter "Christof Meerwald" <cmeerw web.de> wrote in message news:autg6u$1e2h$1 digitaldaemon.com...On Tue, 31 Dec 2002 14:18:54 -0800, Walter wrote:I've fixed the first issue, 'Error: 'f' previously declared as something else'. But I think the other two should be ambiguous, I cannot find a Dec 31 2002
|