What is the function of const specifier in enum types?Cast int to enum in C#What are the differences between a pointer variable and a reference variable in C++?Create Generic method constraining T to an EnumHow do I enumerate an enum in C#?What is the preferred syntax for defining enums in JavaScript?How to get an enum value from a string value in Java?What is the difference between const int*, const int * const, and int const *?What is the “-->” operator in C++?Comparing Java enum members: == or equals()?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?
Horizontal, Slanted, Stacked Lines in TikZ
Distinguish the explanations of Galadriel's test in LotR
What is a writing material that persists nearly forever or for a long time?
What does Middle English "bihiȝten" mean?
How to build up towards a "Moment of Reckoning" when my story is told in the first person?
Conditions for Roots of a quadratic equation at infinity
How do I explain that I don't want to maintain old projects?
Swapping "Good" and "Bad"
What was this character's plan?
Is there a way I can open the Windows 10 Ubuntu bash without running the ~/.bashrc script?
What is the identity for Tuples?
Party going through airport security at separate times?
IX-NAY on the IX-SAY
Can a landlord force all residents to use the landlord's in-house debit card accounts?
How was the Shuttle loaded and unloaded from its carrier aircraft?
VHDL: is there a way to create an entity into which constants can be passed?
How does the Melf's Minute Meteors spell interact with the Evocation wizard's Sculpt Spells feature?
Why is the ladder of the LM always in the dark side of the LM?
Would a carnivorous diet be able to support a giant worm?
Why is the Cauchy Distribution is so useful?
What is the meaning of “Can I have a slice?” In NYC?
What exactly is a "murder hobo"?
Why AI became applicable only after Nvidia's chips were available?
How insert vertex in face?
What is the function of const specifier in enum types?
Cast int to enum in C#What are the differences between a pointer variable and a reference variable in C++?Create Generic method constraining T to an EnumHow do I enumerate an enum in C#?What is the preferred syntax for defining enums in JavaScript?How to get an enum value from a string value in Java?What is the difference between const int*, const int * const, and int const *?What is the “-->” operator in C++?Comparing Java enum members: == or equals()?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
enum foo : const unsigned int
F,
S,
T
;
void func()
foo p;
p = F;
The above compiles so the underlying type is not a const type?
c++ c++11 enums const language-lawyer
add a comment |
enum foo : const unsigned int
F,
S,
T
;
void func()
foo p;
p = F;
The above compiles so the underlying type is not a const type?
c++ c++11 enums const language-lawyer
add a comment |
enum foo : const unsigned int
F,
S,
T
;
void func()
foo p;
p = F;
The above compiles so the underlying type is not a const type?
c++ c++11 enums const language-lawyer
enum foo : const unsigned int
F,
S,
T
;
void func()
foo p;
p = F;
The above compiles so the underlying type is not a const type?
c++ c++11 enums const language-lawyer
c++ c++11 enums const language-lawyer
edited Jul 3 at 1:25
songyuanyao
99.9k11 gold badges197 silver badges263 bronze badges
99.9k11 gold badges197 silver badges263 bronze badges
asked Jun 30 at 10:48
ThomasThomas
5173 silver badges12 bronze badges
5173 silver badges12 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The const
qualifier is ignored in the specification of enum-base; which just expects an integral type to be used as the underlying type of the enumeration type, specifying const
(or volatile
) doesn't make much sense.
(emphasis mine)
colon (:), followed by a type-specifier-seq that names an integral type (if it is cv-qualified, qualifications are ignored) that will serve as the fixed underlying type for this enumeration type
From the standard, [dcl.enum]/2:
(emphasis mine)
The type-specifier-seq of an enum-base shall name an integral type; any cv-qualification is ignored.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56824226%2fwhat-is-the-function-of-const-specifier-in-enum-types%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The const
qualifier is ignored in the specification of enum-base; which just expects an integral type to be used as the underlying type of the enumeration type, specifying const
(or volatile
) doesn't make much sense.
(emphasis mine)
colon (:), followed by a type-specifier-seq that names an integral type (if it is cv-qualified, qualifications are ignored) that will serve as the fixed underlying type for this enumeration type
From the standard, [dcl.enum]/2:
(emphasis mine)
The type-specifier-seq of an enum-base shall name an integral type; any cv-qualification is ignored.
add a comment |
The const
qualifier is ignored in the specification of enum-base; which just expects an integral type to be used as the underlying type of the enumeration type, specifying const
(or volatile
) doesn't make much sense.
(emphasis mine)
colon (:), followed by a type-specifier-seq that names an integral type (if it is cv-qualified, qualifications are ignored) that will serve as the fixed underlying type for this enumeration type
From the standard, [dcl.enum]/2:
(emphasis mine)
The type-specifier-seq of an enum-base shall name an integral type; any cv-qualification is ignored.
add a comment |
The const
qualifier is ignored in the specification of enum-base; which just expects an integral type to be used as the underlying type of the enumeration type, specifying const
(or volatile
) doesn't make much sense.
(emphasis mine)
colon (:), followed by a type-specifier-seq that names an integral type (if it is cv-qualified, qualifications are ignored) that will serve as the fixed underlying type for this enumeration type
From the standard, [dcl.enum]/2:
(emphasis mine)
The type-specifier-seq of an enum-base shall name an integral type; any cv-qualification is ignored.
The const
qualifier is ignored in the specification of enum-base; which just expects an integral type to be used as the underlying type of the enumeration type, specifying const
(or volatile
) doesn't make much sense.
(emphasis mine)
colon (:), followed by a type-specifier-seq that names an integral type (if it is cv-qualified, qualifications are ignored) that will serve as the fixed underlying type for this enumeration type
From the standard, [dcl.enum]/2:
(emphasis mine)
The type-specifier-seq of an enum-base shall name an integral type; any cv-qualification is ignored.
edited Jul 3 at 1:26
answered Jun 30 at 10:50
songyuanyaosongyuanyao
99.9k11 gold badges197 silver badges263 bronze badges
99.9k11 gold badges197 silver badges263 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f56824226%2fwhat-is-the-function-of-const-specifier-in-enum-types%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown