Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 979485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:13:33+00:00 2026-05-16T04:13:33+00:00

The following piece of code is a reduced sample from the large project I’m

  • 0

The following piece of code is a reduced sample from the large project I’m trying to port from GCC/G++ to Microsoft Visual C++ 2010. It compiles fine with G++, but with MSVC++, it throws errors, and I’m having trouble understanding why.

template <typename A, typename B = typename A::C::D>    // line 1
struct foo
{
  typedef int type;
};

template <template <typename> class E, typename T>
typename foo<E<T> >::type                               // line 8
bar(){}

The error messages from MSVC++ are:

example1.cpp(1) : error C2027: use of undefined type 'E<T>'
example1.cpp(8) : error C2146: syntax error : missing ',' before identifier 'D'
example1.cpp(8) : error C2065: 'D' : undeclared identifier

I’ve tried a few changes to narrow down the problem a bit, and while I don’t fully understand it, here’s what I’ve discovered: If in line 1 I replace A::C::D with A::C, it works fine. If I replace template <typename> class E with just typename E and make that foo<E>, it works fine. If explicitly specify the second template argument to foo in line 8, like so, it works fine:

typename foo<E<T>, typename E<T>::C::D>::type          // line 8

And, if I replace the use of A::C::D with something innocuous like typename B = A in line 1, but add a different use of A::C::D as typedef typename A::C::D qux; to the definition of foo, that also works fine.

Any ideas? What bit of C++ rules am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:13:33+00:00Added an answer on May 16, 2026 at 4:13 am

    I reported this as a bug with Microsoft as per jpalecek’s suggestion, and Microsoft has confirmed that it is indeed a fault in their compiler:

    https://connect.microsoft.com/VisualStudio/feedback/details/576196

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following piece of code in Visual C++ 2005 : : class
The following piece of code shows an Insert table dialog: Dialog d = WordApp.Dialogs[WdWordDialog.wdDialogTableInsertTable];
I have the following piece of code pattern: void M1(string s, string v) {
I have the following piece of code which replaces template markers such as %POST_TITLE%
I used the following piece of code in the service to debug the service
I've got the following piece of code in an aspx webpage: Response.Redirect(/Someurl/); I also
I have trouble with the following piece of code. When I go through with
I was reading a book on templates and found the following piece of code:
Consider the following piece of Java code. int N = 10; Object obj[] =
I'm using the following piece of Objective-C code to format a NSNumber, and it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.