Search

namespaces are ignored on template template parameters by Krishty

Closed
as Deferred Help for as Deferred

5
0
Sign in
to vote
Type: Bug
ID: 778488
Opened: 2/4/2013 11:15:45 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
With template template parameters, Visual C++ fails to determine the correct type if two or more parameters have the same class name, but from different namespaces. It seems like only the very last fraction of the class name is considered.
Details (expand)

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

Visual Studio 2012

Steps to reproduce

namespace Namespace1 {

    template <typename T>
    struct SameName { };

}

namespace Namespace2 {

    template <typename T>
    struct SameName {
        static void foo() { }
    };

}

template <
    template <typename> class SameName1,
    template <typename> class SameName2
> struct Foo
    : SameName1<void>, SameName2<void>
{
    static void hellBreaksLoose() {
        SameName2<void>::foo();
    }

};

void main() {
    Foo<Namespace1::SameName, Namespace2::SameName>::hellBreaksLoose();
}

Product Language

English

Operating System

Windows 7 SP1

Operating System Language

English

Actual results

error C2387: 'SameName<void>' : ambiguous base class
error C2039: 'foo' : is not a member of 'Namespace1::SameName<T>'

i.e., compiler confused about whether SameName<void> from Namespace1 or Namespace2 is to be used

Expected results

successful build, because the template parameter name is absolutely unambigous

this can be achieved by
1) renaming the base classes to different names (but that's why C++ has namespaces in the first place!); or
2) typedef'ing the template parameters and using these typedef's to access base class functions
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 2/4/2013 at 9:55 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 2/4/2013 at 11:51 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.