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

  • Home
  • SEARCH
  • 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 4553692
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:58:58+00:00 2026-05-21T16:58:58+00:00

I have the following code, it compiles with gcc 4.4 with no warnings, and

  • 0

I have the following code, it compiles with gcc 4.4 with no warnings, and returns 42.

template<typename T>
struct foo
{ };

template<typename T>
struct foo<void (T)>
{
  enum { value = 42 };
};

int main()
{
  return foo<void ((int))>::value;
}

Now, I see why it should work when the template parameter is void (int), but what’s the deal with the double parentheses? Is this legal in C++? Is it the same as void (int)?

Cheers

  • 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-21T16:58:58+00:00Added an answer on May 21, 2026 at 4:58 pm

    In this case, void ((int)) is identical to void (int).
    void ((int)) part in foo<void ((int))> is called type-id.
    According to §8.1/1, type-id is composed of
    type-specifier-seq and abstract-declarator.
    In void ((int)), type-specifier-seq is void and abstract-declarator
    is ((int)),
    and abstract-declarator can be parenthesized arbitrarily.
    This is legal in C and C++.

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

Sidebar

Related Questions

I have the following code in an NSView subclass: - (id)forwardingTargetForSelector:(SEL)aSelector { if ([super
I recently stumbled across the following behaviour of gcc 3.2.2 writing a c program:
Ahh, C++ templates... The code I see, makes sense to me, but GCC... it
I have been developing a library that is getting pretty large, and now I
I have a C application I am trying to compile for Mac OS X
Possible Duplicate: Making an undefined class as friend, and defining it later. I have
I use the Airplay SDK which is a platform for building C++ apps for
I've been reading about strict aliasing quite a lot lately. The C/C++ standards say
I'm implementing a sql parser in lex and yacc, in that I use a
I just tried out the latest LLVM and Clang trunk versions. They compiled without

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.