title: C++ enum identifiers to String
body: <p>I am trying to convert an C++ identifier into a string. So if I have the following enum</p>
  <pre class="lang-cpp prettyprint-override"><code>enum Example {
      EXAMPLE0,
      EXAMPLE1
  };
  </code></pre>
  <p>I am currently using a little inline function to realise the conversion:</p>
  <pre class="lang-cpp prettyprint-override"><code>inline std::string example_to_string(Example e) {
      switch (e) {
          case EXAMPLE0: return &quot;EXAMPLE0&quot;; break;
          case EXAMPLE1: return &quot;EXAMPLE1&quot;; break;
          default:       return &quot;&quot;; break;
      }
  }
  </code></pre>
  <p>Is there a better way to do this? I have looked everywhere but didn't find anything. In the case above its okay. However, I have larger enums with many identifiers and would love to automate the process.</p>