Creating a string list and an enum list from a C++ macro

后端 未结 8 1282
误落风尘
误落风尘 2020-12-14 08:26

In order to make my code shorter and easier to change I want to replace something like

enum{ E_AAA, E_BBB, E_CCC };
static const char *strings{\"AAA\", \"BBB         


        
8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-14 08:58

    For a simple solution, I'd recommend something like X-Macros.

    For a more complex solution that adds several other features (like range checking, enhanced type safety, optional associated data, etc.), there's a proposed (but never finalized) Boost.Enum library.

提交回复
热议问题