bitshares1-core icon indicating copy to clipboard operation
bitshares1-core copied to clipboard

Use C++11 enum class for enums

Open theoreticalbts opened this issue 10 years ago • 1 comments

C++11 contains enum class, see for example: http://www.cprogramming.com/c++11/c++11-nullptr-strongly-typed-enum-class.html

The enum class construct has two advantages:

  • Specify a specific size of integer
  • Enum values are placed in a namespace

The main thing keeping this from being a dumb search/replace refactoring is that AFAICT the (completely undocumented) enum serialization mechanism of FC is not aware of enum class.

This is obviously a relatively low priority code tidiness issue. My main purpose of posting it here is to get it out of my head and into a ticket.

theoreticalbts avatar Feb 10 '15 20:02 theoreticalbts

At the time fc was written not all compilers supported the enum class (VC++ looking at you).

We would have to update fc reflection to identify this and then fc serialization to leverage it. It also wouldn't work for cases where we want to serialize as a varint.

bytemaster avatar Feb 11 '15 13:02 bytemaster