title: Resolve enum class variable name to string
body: <p>Consider, I have got the following <code>enum</code> class:</p>
  <pre><code>enum class TestEnum
  {
     None = 0,
     Foo,
     Bar
  };
  </code></pre>
  <p>I'd like to specify <code>ostream operator ( &lt;&lt; )</code> for this <code>enum</code> class, so I could write:</p>
  <pre><code>std::cout &lt;&lt; &quot;This is &quot; &lt;&lt; TestEnum::Foo;
  </code></pre>
  <p>and get following output <code>This is Foo</code>.</p>
  <p>My question is:<br />
  <strong>Is there any place where enum &quot;<em>name specifiers</em>&quot;  are stored? (i.e. for <code>enum class </code>TestEnum it is <code>None</code>, <code>Foo</code> and <code>Bar</code>)</strong> So I could write a function (or at best function template) that specifies <code>ostream</code> operator for this <code>TestEnum</code> like:</p>
  <pre><code>std::ostream&amp; operator&lt;&lt; ( std::ostream&amp; os, TestEnum aEnum ) {
     return std::string( aEnum.name() );
  }
  </code></pre>
  <p>So far, I did it this way:</p>
  <pre><code>std::ostream&amp; operator&lt;&lt; ( std::ostream&amp; os, TestEnum aEnum ) {
     switch( aEnum )
     {
     case TestEnum::Foo:
         os &lt;&lt; &quot;Foo&quot;;
         break;
     case TestEnum::Bar:
         os &lt;&lt; &quot;Bar&quot;
         break;
     }
     return os;
  }
  </code></pre>
  <p>I have seen some solutions using <code>boost</code> library, but I would prefer not using it this time.</p>