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;








25















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?










share|improve this question






























    25















    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?










    share|improve this question


























      25












      25








      25


      1






      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?










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      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






















          1 Answer
          1






          active

          oldest

          votes


















          28














          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.







          share|improve this answer
























            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
            );



            );













            draft saved

            draft discarded


















            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









            28














            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.







            share|improve this answer





























              28














              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.







              share|improve this answer



























                28












                28








                28







                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.







                share|improve this answer















                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.








                share|improve this answer














                share|improve this answer



                share|improve this answer








                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


















                    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.



















                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?