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 867733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:01:41+00:00 2026-05-15T10:01:41+00:00

I’m porting my c++ windows code (msvc & intel) to Linux (g++). The code

  • 0

I’m porting my c++ windows code (msvc & intel) to Linux (g++). The code uses lots of templates (I like metaprogramming ;-). But I can’t compile this code:

template <class TA>
struct A
{
    template <class TAB> struct B;
};


template <class TC>
struct C {};


template <class TD>
struct D
{
    template <class TTD> class T {};
};


template<class TA>
    template<class TBA>
struct A<TA>::B : C<typename D<TA>::T<TBA> >
{
    int foo;
};

g++ tells me that in definition of A::B, C class has invalid template arguments. But on msvc and intel it works well! What’s the problem here?
PS: Sorry, I can’t post the original code, because it’s too template-complicated. But this example is virtually the same and gives the same error on g++.
Thank you.

UPDATE: I’ve found the problem is in TBA argument of T. g++ doensn’t like usage of second template in the definition.

  • 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-15T10:01:41+00:00Added an answer on May 15, 2026 at 10:01 am

    You need the template keyword

    template<class TA>
        template<class TBA>
    struct A<TA>::B : C<typename D<TA>::template T<TBA> >
    {
        int foo;
    };
    

    GCC is correct to give a diagnostic here. This is because T cannot be looked up in the dependent scope D<TA>. The meaning of the < after it depends on whether T is a template or not. The Standard says that T shall be assumed to be not a template and thus T cannot be followed by a template argument list.

    template is like typename in that it tells the compiler to treat T as a template and that the < is the start of an argument list in any case. The Standard says in paragraphs 14.2/2 and 14.2/4

    For a template-name to be explicitly qualified by the template arguments, the name must be known to refer
    to a template.

    When the name of a member template specialization appears after . or -> in a postfix-expression, or after nested-name-specifier in a qualified-id, and the postfix-expression or qualified-id explicitly depends on a template-parameter (14.6.2), the member template name must be prefixed by the keyword template. Otherwise the name is assumed to name a non-template.

    In your case, you have T appear after the nested-name-specifier D<TA> which depends on the template-parameter TA. For the typename-specifier to parse correctly, the construct D<TA>::T<TBA> must interpret T as the name of a class template, which 14.2 forbids.


    On that topic, it’s always a good idea to try and compile with Clang

    main1.cpp:21:37: error: use 'template' keyword to treat 'T' as a dependent template name
    struct A<TA>::B : C<typename D<TA>::T<TBA> >
                                        ^
                                        template 
    1 error generated.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 437k
  • Answers 437k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I have successfully introduced it into a project that had… May 15, 2026 at 4:08 pm
  • Editorial Team
    Editorial Team added an answer I can't reproduce this behavior. It's running fine against http://cmis.alfresco.com… May 15, 2026 at 4:08 pm
  • Editorial Team
    Editorial Team added an answer Fascinating, I've not seen this before: /regex/(...); EDIT: see this!… May 15, 2026 at 4:08 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.