0

I would like to have some macro for c++ that would let me do something like

ENUM_START(pups)
ENUM_VALUE(ROCKY, "Trash Dog")
ENUM_VALUE(MARSHALL, "Fireman Pup")
ENUM_END

such that I can switch on an enum of type pups, but also create some function like ROCKY.get_name() to return the string such as "Trash Dog"

Jamba
  • 1
  • 1
    Does this answer your question? [enum to string in modern C++11 / C++14 / C++17 and future C++20](https://stackoverflow.com/questions/28828957/enum-to-string-in-modern-c11-c14-c17-and-future-c20) – cigien May 19 '20 at 22:37
  • That is a very helpful answer, but it only allows the enum name and its string to be the same, ROCKY : "ROCKY", as opposed to ROCKY : "Trash Dog" – Jamba May 20 '20 at 00:25
  • There are several answers to that question that let you have arbitrary strings. – cigien May 20 '20 at 00:59

0 Answers0