I've gotten in the habit of using the new enum classes (or strong enums) in C++. Now, I need to deprecate a member.
However, the standard enum deprecation syntax, as described in the following question, does not compile. c++ mark enum value as deprecated?
This was my expectation:
enum class MyEnum {
ORIGINAL [[deprecated("Use `PRIMARY` instead.")]] = 1,
PRIMARY = 1,
SECONDARY = 2,
THIRD = 3
};
Result:
...: error: expected '}' before '[' token
ORIGINAL [[deprecated]] = 1,
^
On second glance, I can see that this syntax is intended for enum MyEnum ...
, as opposed to enum class MyEnum ...
.
I can't seem to find anything about it on CPP Reference either: https://en.cppreference.com/w/cpp/language/attributes/deprecated
Am I missing something, or what is the appropriate way to deprecate a member of an enum class
?