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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:19:02+00:00 2026-06-07T17:19:02+00:00

Standardese: [class.ctor] 12.1/1 says A special declarator syntax is used to declare or define

  • 0

Standardese:

[class.ctor] 12.1/1 says

A special declarator syntax is used to declare or define the constructor. The syntax uses:

    — an optional decl-specifier-seq in which each decl-specifier is either a function-specifier or constexpr,

    — the constructor’s class name, and

    — a parameter list

in that order.

[class.name] 9.1/4 says

A typedef-name (7.1.3) that names a class type, or a cv-qualified
version thereof, is also a class-name. If a typedef-name that names a
cv-qualified class type is used where a class-name is required, the
cv-qualifiers are ignored. A typedef-name shall not be used as the
identifier in a class-head.

Also [expr.prim.general] 5.1.1/8 says

Where class-name :: class-name is used, and the two class-names refer
to the same class, this notation names the constructor (12.1).


Application:

This seems to me to say that declaring a constructor should be allowed using typedef names (despite the fact that 12.1/1 doesn’t use an italicized class-name).

For example, given:

struct Foo;
typedef Foo Bar;

then

struct Foo { Bar() {} }; // defines Foo's constructor. - 1

or instead given

struct Foo;
struct Foo { Foo() };
typedef Foo Bar;

then

Foo::Bar() {}; // defines Foo's constructor - 2

or

Bar::Bar() {}; // defines Foo's constructor - 3

or

Bar::Foo() {}; // defines Foo's constructor - 4

Any of these should be legal. However nobody seems to accept definitions 2 or 3, MSVC accepts 1, and MSVC, clang, and gcc all accept 4.

Is my analysis correct, and are all these compilers wrong?

  • 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-06-07T17:19:04+00:00Added an answer on June 7, 2026 at 5:19 pm

    §12.1/3 of the working draft N3337 (Feb 2012) states

    A typedef-name shall not be used as the class-name in the declarator-id for a constructor declaration.

    This rules out (1).

    §12.1/1 seems to use the term “declaration” for both declarations and definitions:

    A special declarator syntax is used to declare or define the constructor. […] In such a declaration, […]

    (without referring to “definitions” explicitly). I think it’s a bit unclear whether this applies to out-of-class definitions or only to inline definitions. If it applies to all kinds of definitions, this would rule out (2) and (3) as well. (4) should be legal in any case.

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

Sidebar

Related Questions

I have several files with code testing code (which uses a unittest class). Later
Example: // can't forward declare with class Foo::Bar // actual class class Foo {
Which is the right way to call base class move ctor? this (works in
I'd like to be able to declare a Java class Ref such that I
I have a class defined as final. Does it make sense to define the
I have a class which is used to show correct message. This class works
I have a class whose objects are used in shared memory. Therefore, I must
I'm looking into development standards fro JavaScript. I had previously used Doulgas Crockfords Javascript
Which HTML tags can use the class attribute? (In which standards — e.g. HTML/XHTML/HTML5
To ensure coding standards I have a couple of unit test which uses reflection

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.