title: How do you import an enum into a different namespace in C++?
body: <p>I have an enum in a namespace and I'd like to use it as if it were in a different namespace. Intuitively, I figured I could use 'using' or 'typedef' to accomplish this, but neither actually work. Code snippet to prove it, tested on GCC and Sun CC:</p>
  
  <pre><code>namespace foo
  {
  
  enum bar {
      A
  };
  
  }
  
  namespace buzz
  {
  // Which of these two methods I use doesn't matter,
  // the results are the same.
  using foo::bar;
  //typedef foo::bar bar;
  }
  
  int main()
  {
      foo::bar f; // works
      foo::bar g = foo::A; // works
  
      buzz::bar x; // works
      //buzz::bar y = buzz::A; // doesn't work
      buzz::bar z = foo::A;
  }
  </code></pre>
  
  <p>The problem is that the enum itself is imported but none of its elements. Unfortunately, I can't change the original enum to be encased in an extra dummy namespace or class without breaking lots of other existing code. The best solution I can think of is to manually reproduce the enum:</p>
  
  <pre><code>namespace buzz
  {
  enum bar
  {
      A = foo::A
  };
  }
  </code></pre>
  
  <p>But it violates the <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself" rel="noreferrer">DRY principle</a>. Is there a better way?</p>