c++ mark enum value as deprecated?

后端 未结 8 1774
再見小時候
再見小時候 2020-12-30 23:41

Is it possible to mark an enum value as deprecated?

e.g.

enum MyEnum {
    firstvalue = 0
    secondvalue,
    thirdvalue, // deprecated
    fourthva         


        
相关标签:
8条回答
  • 2020-12-31 00:40

    Using compiler dependent pragmas: Here is the documentation for Gcc and Visual Studio.

    0 讨论(0)
  • 2020-12-31 00:44

    You can declare enum constants outside an enum declaration:

    enum MyEnum {
        firstvalue = 0
        secondvalue,
        thirdvalue
    };
    __attribute__ ((deprecated)) const MyEnum fourthvalue = MyEnum(thirdvalue + 1);
    
    0 讨论(0)
提交回复
热议问题