Search

error C2914: 'foo' : cannot deduce template argument as function argument is ambiguous by Jinhao.CPP

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 726039
Opened: 2/21/2012 7:03:29 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
0
User(s) can reproduce this bug
bad overloading

---
class A
{
public:
    void foo() const
    {}

    void foo()
    {}
};

template<typename R, typename T>
void test(R(T::*)() const)
{
}

int main()
{
    test(&A::foo); //Error here.
}
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling version

Visual Studio 2010 SP1

Steps to reproduce

class A
{
public:
    void foo() const
    {}

    void foo()
    {}
};

template<typename R, typename T>
void test(R(T::*)() const)
{
}

int main()
{
    test(&A::foo); //Error here.
}

it generates:
error C2914: 'foo' : cannot deduce template argument as function argument is ambiguous
error C2784: 'void foo(R (__thiscall T::* )(void) const)' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'

the expected result is:
void A::foo() const should be matched by template function test()

Product Language

English

Operating System

Windows 7

Operating System Language

Chinese (Simplified)

Actual results

error C2914: 'foo' : cannot deduce template argument as function argument is ambiguous
error C2784: 'void foo(R (__thiscall T::* )(void) const)' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'

Expected results

void A::foo() const should be matched by template function test()
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 4/27/2012 at 4:57 PM
Hello,

Thank you for reporting this bug. We've fixed the bug for Release Candidate of Visual Studio 11. Next major release of Visual Studio will have the fix.

Thanks,
Ulzii Luvsanbat
Visual C++ Team
Posted by MS-Moderator09 [Feedback Moderator] on 2/22/2012 at 1:46 AM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 2/21/2012 at 7:43 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.