C++ Trickery : output actual enum, not its value
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3342726/c-print-out-enum-value-as-text">C++: Print out enum value as text</a>  </p>
</blockquote>



<p>Say I have an enumeration:</p>

<pre><code>typedef enum MyEnum_
{
  MY_ENUM_BLUE,
  MY_ENUM_RED,
  MY_ENUM_GREEN
} MyEnum;
</code></pre>

<p>And that I have a method that gets an "MyEnum" as parameter. I'd like write to log file the value of that MyEnum, but I don't want 0, 1 or 2 to appear there--- I'd like to output the actual enumeration string "MY_ENUM_xxxx", of course <strong>without a switch/case block</strong>..... and dealing with each value individually.</p>

<p>Is there some trickery or pattern, in c++ or using macros that would help me achieve that?</p>
