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

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form