title: Correct way to use enums with pass-by-value and return in functions?
body: <p>I understand the question title is mightily vague, hence the body text :)</p>
  
  <p>I have several <code>enum</code>s I use for identifying file types and other stuff that needs easy differentiating. My former approach was this:</p>
  
  <pre><code>namespace my_namespace
  {
      namespace fileType
      {
          enum fileType
          {
              SOURCE,
              HEADER,
              RESOURCE
          };
      }
  }
  using namespace my_namespace::fileType;
  </code></pre>
  
  <p>Which allowed me to define a function:</p>
  
  <pre><code>fileType someFunction( const std::string &amp;someFile, const fileType someType )
  {
      //...
      return fileType::HEADER;
  }
  </code></pre>
  
  <p>And I could define and compare variables like this:</p>
  
  <pre><code>fileType type = fileType::SOURCE;
  </code></pre>
  
  <p>Which is awesome. Though there were some caveats. Headers (without any <code>using</code> directives) required doubling the intended enum name to let the compiler know you're using the type, not namespace:</p>
  
  <pre><code>my_namespace::fileType::fileType soeFunction( const std::string &amp;someFile, const my_namespace::fileType::fileType someType );
  </code></pre>
  
  <p>Which does look silly, is hard to read and painful to understand. Additionally, MSVC complains at warning level one about a non-standard extension used (due to the doule <code>fileType</code> in the example). Strange that GCC does not complain at the strictest settings, but hey, that's a different story.</p>
  
  <p>I now want to rewrite my <code>enum</code>s in a way that they are (anonymously) enclosed in a struct instead of a namespace, allowing for the single qualification when declaring functions, thus shutting up MSVC's warning. But How do I write the <code>return</code> statement in this case. Is it absolutely necessary to provide a constructor/conversion operator or is there a way around this I did not see?</p>
  
  <p>Example:</p>
  
  <pre><code>// enum definition
  namespace my_namespace
  {
      struct fileType
      {
          enum
          {
              SOURCE,
              HEADER,
              RESOURCE
          };
      }
  }
  using my_namespace::fileType;
  
  // function declaration in header
  my_namespace::fileType someFunction( const std::string &amp;s, const my_namespace::fileType type );
  
  // function implementation in .cpp file
  using my_namespace::fileType;
  
  fileType someFunction( const string &amp;s, const fileType type )
  {
      //...(problem is situated below)
      return fileType::SOURCE;
  }
  </code></pre>
  
  <p>This illustrated what I'd like to do. I'd like to avoid explicitely calling the enum struct's constructor: <code>fileType(fileType::SOURCE)</code> which would leave me with a double <code>fileType</code> use.</p>
  
  <p>Thanks for the help!</p>
  
  <p>PS: if this question has been answered before, I apologize, but I didn't find a good alternative with google or on SO's previous questions on this subject.</p>