title: Is there a way to specify an enum-class value without having to type out its scope every time?
body: <p>I have some functions that can return either success or one of a fixed set of error codes.  To identify the error codes, I had (something like) this old-school C-style enum declared:</p>
  
  <pre><code>enum {
     RESULT_ERROR_BAD_PARAMETER = -3,
     RESULT_ERROR_FILE_NOT_FOUND = -2,
     RESULT_ERROR_GENERAL = -1,
     RESULT_SUCCESS = 0
  };
  typedef int my_status_t;
  
  my_status_t MyFunc();   // returns a RESULT_* value
  </code></pre>
  
  <p>This worked pretty well; the calling pattern would be something like:</p>
  
  <pre><code>if (MyFunc() != RESULT_SUCCESS) printf("Error!\n");
  </code></pre>
  
  <p>... however it was uncomfortably permissive about allowing implicit conversions of <code>my_status_t</code> values to int/bool/etc, allowing careless mistakes like this:</p>
  
  <pre><code>// Compiles but does the wrong thing at run-time -- bad!
  if (MyFunc() == false) printf("Error!\n");
  </code></pre>
  
  <p>... so in my new code revision, I converted it to be an <code>enum class</code> instead:</p>
  
  <pre><code>enum class my_status_t {
     RESULT_ERROR_BAD_PARAMETER = -3,
     RESULT_ERROR_FILE_NOT_FOUND = -2,
     RESULT_ERROR_GENERAL = -1,
     RESULT_SUCCESS = 0
  };
  </code></pre>
  
  <p>... this works great from a compile-time checking perspective; now most unintentional type-promotions are caught by the compiler, forcing the programmer to go back and do it the right way.</p>
  
  <p>The only thing that bothers me is that the new syntax is tedious:  now I have to write something like:</p>
  
  <pre><code>if (MyFunc() != my_status_t::RESULT_SUCCESS) printf("Error!\n");
  </code></pre>
  
  <p>... at every call site -- having to type out <code>my_status_t::</code> each time is tedious and makes the code harder to read, without really adding much value (since <code>RESULT_SUCCESS</code> is sufficiently unique for my purposes on its own, anyway)</p>
  
  <p>My question is, is there some kind of <code>using namespace my_status_t;</code> style directive I could use to tell the compiler to export the enum-values out of their <code>my_status_t</code> namespace, so that I could reference them without having to type the <code>my_status_t::</code> prefix all the time?</p>