Search

template class member function overload ambiguity by Butterflow

Closed
as Fixed Help for as Fixed

3
Sign in to vote
0
Sign in to vote
Sign in
to vote
Type: Bug
ID: 101619
Opened: 4/22/2006 8:17:29 AM
Access Restriction: Public
0
Workaround(s)
2
User(s) can reproduce this bug
VC2005 can not resolve the template class member function overload while VC6, VC2003, DEV C++ can for the same code.
Details (expand)
Product Language
English
Version
Visual Studio 2005
Category
Language/Compiler
Operating System
Windows XP Professional
Operating System Language
English
Steps to Reproduce
==========

template<typename R, typename T1>
class foo
{
public:
template<typename U, typename T>
void bind(R (U::*)(T1) const, T * obj) { }; // (a)

template<typename U, typename T>
void bind(R (U::*)(T1) const, T & obj) { }; // (b)
};

class bar
{
public:
void foobar(int) const { }
};

int _tmain(int argc, _TCHAR* argv[])
{
foo<void, int> testfoo;

bar * pb = 0;
testfoo.bind(&bar::foobar, pb); // 'error C2668: 'foo<R,T1>::bind' : ambiguous call to' only in VC8

return 0;
}

==========

The above code generate compile error only in VC2005. The same code compile successfuly in VC6, VC2003, DEV C++,

while following two other code snipets compile successfully in VC2005, VC2003, VC6, DEV C++.

==========

class foo
{
public:
template<typename T>
void bind(T * obj) { }; // (a)

template<typename T>
void bind(T & obj) { }; // (b)
};

class bar { };

int _tmain(int argc, _TCHAR* argv[])
{
foo testfoo;
bar * pb = 0;
testfoo.bind(pb); // match (a)
return 0;
}

==========

template<typename R, typename T1>
class foo
{
public:
template<typename U, typename T>
void bind(R (U::*)(T1), T * obj) { }; // (a)

template<typename U, typename T>
void bind(R (U::*)(T1), T & obj) { }; // (b)
};

class bar
{
public:
void foobar(int) { }
};

int _tmain(int argc, _TCHAR* argv[])
{
foo<void, int> testfoo;

bar * pb = 0;
testfoo.bind(&bar::foobar, pb); // match (a)

return 0;
}

==========
Actual Results
'error C2668: 'foo<R,T1>::bind' : ambiguous call to'
Expected Results
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 4/26/2006 at 2:38 PM
Thanks for reporting the issue! One of our developers is currently looking into it.

Thanks,
Ayman Shoukry
Program Manager
VC++ Team
Posted by Microsoft on 5/10/2006 at 3:42 PM
The Microsoft Sub-status is now "Working on solution"
Posted by Microsoft on 5/11/2006 at 12:30 PM
The Microsoft Sub-status is now "Working on solution"
Posted by Microsoft on 5/11/2006 at 1:26 PM
The Microsoft Sub-status is now "Working on solution"
Posted by Microsoft on 5/12/2006 at 9:18 AM
Hi: a fix for this issue has been checked into the compiler sources: the fix should show up in the next release of Visual C++.

Thanks for reporting the issue.

Jonathan Caves
Visual C++ Compiler Team