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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:19:31+00:00 2026-06-15T10:19:31+00:00

Note that the following two functions have the same type and signature: void foo1(int

  • 0

Note that the following two functions have the same type and signature:

void foo1(int t) {} // foo1 has type 'void(*)(int)', and signature '(*)(int)'
void foo2(const int t) {} // Also type 'void(*)(int)', signature '(*)(int)'

(the const is not part of the function type or function signature). Similarly, a modifier (const or volatile) on the return type does not influence the function type or function signature.

However, in the function definition itself (not shown), the named variable t does maintain the const qualification in foo2.

There are many StackOverflow questions discussing why the return type of the function is not considered as part of the function signature (used for overload resolution).

However, I cannot find any StackOverflow question that asks why argument modifiers (const or volatile) are not part of the function’s type or signature. Also, I have looked directly in the C++11 standards document and find it difficult to unravel.

What is the rationale behind the fact that argument modifiers (i.e., const and volatile) are not part of a function’s type or signature?

ADDENDUM For clarity, from R.MartinhoFernandes’s answer below, I should clarify that in C++ (I think) the argument modifiers const and volatile are only ignored as part of the function type/signature if they are top-level modifiers – see that answer below.

  • 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-15T10:19:32+00:00Added an answer on June 15, 2026 at 10:19 am

    What is the rationale behind the fact that argument modifiers (i.e., const and volatile) are not part of a function’s type or signature?

    From a caller’s perspective, there is no difference between void foo(int) and void foo(int const). Whatever you pass to it will not be modified, regardless of the modifier: the function will get a copy.

    From an implementer’s perspective the sole difference is that with void foo(int x) you can mutate x (i.e. your local copy) in the body, but you cannot mutate x with void foo(int const x).

    C++ acknowledges these two perspectives. The caller’s perspective is acknowledged by making the two declarations void foo(int); and void foo(int const); declare the same function. The implementer’s perspective is acknowledged by allowing you to declare a function as void foo(int x); but define it as void foo(int const x) { /*...*/ } if you want to make sure you don’t accidentally assign to the argument.

    Note that this only applies for top-level const, i.e. const that applies to the whole type. In things like int const& or int const* the modifier only applies to a part of the type, as “pointer to (const (int))”, so it is not top-level const. In int *const however, the const again applies to the whole type as in “const (pointer to (int))”.

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

Sidebar

Related Questions

Suppose you have a Django view that has two functions: The first function renders
So I have a couple of functions that work with a string type I
I'm having the following data set (note that my database/schemata is somewhat complex so
I found the following claim in the documentation for Net::OpenSSH : Note that using
The Erlang documentation states the following about gen_servers: ... Note that for any other
How can I remove the unwanted whitespace in following example? Note 1. that there
I wrote the following simple function that takes two parameters mostly coming from another
Note: I've read the following two questions already: Can you explain the concept of
Possible Duplicate: When are two enums equal in C#? I have the following classes
I have a <div> on my page that refreshes automatically every two minutes with

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.