title: Datastructure to represent a lookup table with "multiple-combined" key
body: <p>How will you design a table datastructure for lookup?</p>
  
  <p>I basically have to represent the following table</p>
  
  <pre><code>Country             Activity        Legal_Age
  European            Drink           18
  European            Drive           21
  American            Drink           21
  American            Drive           18
  </code></pre>
  
  <p>Here my Key is (Country &amp; Activity) and the value is Legal_age.</p>
  
  <p>I thought of using std::map to breakdown this problem (into individual maps) as follows.</p>
  
  <p>national_Activity_age_map</p>
  
  <pre><code>European            European_Activity_age_map
  American            American_Activity_age_map
  </code></pre>
  
  <p>European_Activity_age_map</p>
  
  <pre><code>Drink           18
  Drive           21
  </code></pre>
  
  <p>American_Activity_age_map</p>
  
  <pre><code>Drink           21
  Drive           18
  </code></pre>
  
  <p>But the problem here is, as the number of columns to the original table keeps growing, the number of maps to be added and maintained keeps growing.</p>
  
  <p>Let's say the US chooses to have seperate drinking ages for US-citizens and non-citizens. Then I will have to add new mappings and also modify existing mappings.</p>
  
  <p>Is there a simple &amp; a clean way to represent this data in a DataStructure which takes in a multiple factored Key and produce one value?</p>
  
  <p>There are a few similar questions like below but nothing answers my specific problem.
  <a href="https://stackoverflow.com/questions/1072574/what-datastructure-would-you-use-to-represent-this-format-of-data">What datastructure would you use to represent this format of data?</a></p>
  
  <p>Update:
  I can't use Boost features at work since it has to be ported (or something like that). Is there a C++ (gcc 4.1.2) feature that I can use.</p>