title: Associative Key to Key map in C++
body: <p>I'm searching for something like a "Key to Key" map in C++.</p>
  
  <p>My intention is as follows:</p>
  
  <ul>
  <li>Each Key - either on the "left" or "right" side is unique</li>
  <li>The key of the left side can be looked up by the key of the right side et vice versa</li>
  </ul>
  
  <p>As an example and to make my intention more clear, in code, it would probably look like:</p>
  
  <pre><code>key2key&lt;int, string&gt; myMap; // int maps to string, string to int
  
  myMap.insert(0, "zero");
  myMap.insert(1, "one");
  myMap.insert(2, "two");
  
  myMap.insert(1, "zero"); // would throw an error
  myMap.insert(9, "one"); // would throw an error as well
  
  cout &lt;&lt; myMap.lookupLeft(1) &lt;&lt; endl; // prints "one"
  cout &lt;&lt; myMap.lookupRight("one") &lt;&lt; endl; // prints "1"
  </code></pre>
  
  <p>Of course I could go ahead and implement something like this on my own, but is there anything existing out there?
  I don't want to reinvent the wheel, so maybe it's possible to modify or reuse standard STL containers or boost.</p>
  
  <p>Why do I think that it is useful?</p>
  
  <p>Imagine you're reading a configuration file and you also want to write or make changes to this config file.
  This config file might contain some fields which internally in c++ are represented as type safe enum classes.
  Using a "Key to Key" map is a very lightweight generator and type converter of theses values.</p>
  
  <pre><code>enum class DebugLevel {error, warning, debug};
  const key2key&lt;DebugLevel, string&gt; debugLevelMap = {
    {DebugLevel::error, "error"},
    {DebugLevel::warning, "warning"},
    {DebugLevel::debug, "debug"},
  }
  
  DebugLevel foo = debugLevelMap.lookupRight("error");
  string bar = debugLevelMap.lookupLeft(DebugLevel::warning);
  </code></pre>