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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:21:38+00:00 2026-05-28T15:21:38+00:00

The following code does not compile with gcc 4.7 (20120114) , but compiles fine

  • 0

The following code does not compile with gcc 4.7 (20120114) , but compiles fine with clang++ 3.0. Is this a bug in gcc, clang or just because what I try to do is not allowed in c++11?

template< typename... args >
struct A {
    template< typename head, typename... tags >
    struct Inner : public Inner<tags...> {
    };

    template< typename head >
    struct Inner<head> {
        // assume both args... and tags... must be used to
        // calculate TYPE
        typedef int TYPE;
    };
};

template< typename... args >
struct B : A<args...> {
    template<typename... tags>
    typename A<args...>::template Inner<tags...>::TYPE x() {
        return 0;
    }
};

int main(int argc, const char *argv[]) {
    B<int, int, int> b;
    b.x<char, short, long, double>();

    return 0;
}

The code above is a very simplified example of what I try to do, but the essence is that I need both the args… types and the tags… types to calculate the return type of the function. How can this be done?

  • 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-28T15:21:39+00:00Added an answer on May 28, 2026 at 3:21 pm

    Not sure if it’s a bug of gcc or not, but the standard solution to make it compile on gcc is to declare the empty variadic version and then specialize it:

    template <typename... T> 
    struct Inner;
    template <typename Head, typename... Rest>
    struct Inner<Head, Rest...> : public Inner<Rest...> { ... };
    

    Demo: http://ideone.com/MFKVY

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

Sidebar

Related Questions

The following code compiles in MSVC++, but does not compile in GCC 4.5.1: #include
Following code does compile in gcc 4.5 but it is not being compiled in
Can anyone explain why the following code does not compile (on g++ (GCC) 3.2.3
The following code doesn't compile with gcc, but does with Visual Studio: template <typename
The following code does not compile in gcc: namespace One{ class A{ }; };
This code does not compile for me on GCC version 4.3.2 (Debian 4.3.2-1.1) main()
The following code (condensed from a larger program) does not compile with clang or
The following code does not compile: public class GenericsTest { public static void main(String[]
The following Code does not compile Dim BasicGroups As String() = New String() {Node1,
The following code does not compile, saying error C2248: 'A::getMe' : cannot access private

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.