Search

Separated declaration and definition of a template function using template-of-template does not compile by halfdan

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 738324
Opened: 4/23/2012 11:19:40 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
1
User(s) can reproduce this bug
I'm porting a large library to Windows and ran into the code below, which does not compile in either MSVC 2008 or 2010 (my compiler targets on Windows):

class A
{
    template<typename C, template<typename> class B >
    typename B<C>::type func() const;
};

template< class C, template<typename> class B>
typename B<C>::type A::func() const
{
    return 1;
}

If I modify it to the form below, it compiles quite happily:

class A
{
    template<typename C, template<typename> class B >
    typename B<C>::type func() const
    {
         return 1;
    }
};

This works fine in gcc 4.4, 4.5 and clang (any version).

Details (expand)

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

Visual Studio 2010

Steps to reproduce

Compile this:

class A
{
    template<typename C, template<typename> class B >
    typename B<C>::type func() const;
};

template< class C, template<typename> class B>
typename B<C>::type A::func() const
{
    return 1;
}

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

1>c:\users\halfdan\documents\visual studio 2010\projects\win32tests\main.cpp(11): error C2244: 'A::func' : unable to match function definition to an existing declaration
1>         definition
1>         'B<C>::type A::func(void) const'
1>         existing declarations
1>         'B<C>::type A::func(void) const'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

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/27/2012 at 3:52 PM
Hello,

Thanks for this bug report. This indeed was a bug in compiler. We have fixed the bug now in the next major release of Visual Studio.

Thanks,
Ulzii Luvsanbat
Visual C++ Team
Posted by MS-Moderator08 [Feedback Moderator] on 4/23/2012 at 10:58 PM
Thank you for submitting feedback on Visual Studio 11 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 4/23/2012 at 11:48 AM
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.