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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:48:37+00:00 2026-06-16T03:48:37+00:00

Declarators. Yes, declarators. They are the source of a lot of coding convention debates.

  • 0

Declarators. Yes, declarators. They are the source of a lot of coding convention debates. It’s a really good topic for arguments — C++ doesn’t rule which one is better than the other (it doesn’t care!). And so we can write these without worrying someone might make fun of you:

int x;

int& a = x;
int &b = x;

int* c = &x;
int *d = &x;

In syntactical terms, b and d are “more valid” than the others. We are required to put declarator modifiers before the names:

int m, *n;   // m is an int; n is a pointer to int

But the tide seems to turned in favor of one. With C++11’s variadic templates, the position of declarators seems to be restricted to the form where the modifiers are closer to the base type:

template<typename... Ts>
void VariadicFuncRef(const Ts&... args) { }
                             ^
template<typename... Ts>
void VariadicFuncPtr(Ts*... args) { }
                       ^

It is an error to write these forms:

template<typename... Ts>
void VariadicFuncRef(const Ts... &args) { }

template<typename... Ts>
void VariadicFuncPtr(Ts... *args) { }

For a concrete example, click here.

And so, my question is this:
Why are we limited to this (the legal) form and can’t use the other?

Any thoughts guys?

ADDITIONAL 1: I’m also interested on the design decision on why is this “rule” “enforced”.

  • 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-16T03:48:38+00:00Added an answer on June 16, 2026 at 3:48 am

    First of all, I would not say that int &a is more valid than int& a. You may say it is more readable, or a good practice, but that is a different thing altogether.

    Second, the parameter unpack syntax T... can be read as “the type-pattern on the left side of ... is expanded, forming same or different actual function parameter types matching the form of the type-pattern”. So when you write f(T&...), it can be expanded to f(int&, float&, double&, Xyz&, Abc&). But that doesn’t seem to be so obvious (at least to me) when the syntax is T...&. So maybe, that is one of the several other possible reasons why the Standard made it like that.

    Also note that args in T&...args is optional. So if you don’t write it, then void f(T...&) looks weird (to me, at least) and void f(T&...) looks better aesthetically at least.

    You could also compare syntaxes like : T * const & ... with T... * const &. The type-pattern is more obvious in the former syntax than in the latter.

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

Sidebar

Related Questions

Download source code here: http://www.eyeClaxton.com/download/delphi/ColorSwap.zip Yes, I want to convert something mostly blue to
I'm new to decorators in java, i've discovered that sitemesh offers a good deal
These are my declarations. Why it doesn't identify signed as a type? I have
I have two non-overlapping sets of types and want to make other set which
(Yes, I've read and played around based on answers to similar questions in this
I am getting an error while bundle install $ vi Gemfile source 'http://rubygems.org' gem
I've recently found myself needing (yes, needing) to define absurdly long switch statements and
friends. I'm developing a flex mobile app. I've declared a Titlewindow which contains the
So I've done a lot of research on this and haven't found any answers
I'm trying to add an inline Callout to my networked flex mobile app which

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.