title: Composite key syntax in Boost MultiIndex
body: <p>Even after studying the <a href="http://www.ccp4.ac.uk/ccp4bin/viewcvs/*checkout*/cctbx/cctbx_sources/boost/libs/multi_index/doc/advanced_topics.html#composite_keys" rel="noreferrer">examples</a>, I'm having trouble figuring out how to extract ranges using a composite key on a MultiIndex container. </p>
  
  <pre><code>typedef multi_index_container&lt;
    boost::shared_ptr&lt; Host &gt;,
    indexed_by&lt; 
      hashed_unique&lt; const_mem_fun&lt;Host,int,&amp;Host::getID&gt; &gt;, // ID index
      ordered_non_unique&lt; const_mem_fun&lt;Host,int,&amp;Host::getAgeInY&gt; &gt;, // Age index
      ordered_non_unique&lt; const_mem_fun&lt;Host,int,&amp;Host::getHousehold&gt; &gt;, // Household index
      ordered_non_unique&lt; // Age &amp; eligibility status index
        composite_key&lt;
           Host,
          const_mem_fun&lt;Host,int,&amp;Host::getAgeInY&gt;,
          const_mem_fun&lt;Host,bool,&amp;Host::isPaired&gt;
          &gt;
         &gt;
      &gt; // end indexed_by
    &gt; HostContainer;
  </code></pre>
  
  <p>My goal is to get an iterator pointing to the first of the subset of elements in <code>HostContainer hmap</code> that has age <code>partnerAge</code> and returns <code>false</code> to <code>Host::isPaired()</code>:</p>
  
  <pre><code>  std::pair&lt; hmap::iterator,hmap::iterator &gt; pit = hmap.equal_range(boost::make_tuple( partnerAge, false ) );
  </code></pre>
  
  <p>I think this is very wrong. </p>
  
  <ol><li> How/Where do I specify the iterator index (which should be 3 for age & eligibility)? I will include other composite keys in the future. </li>
  <li> What exactly are the two iterators in <code>std::pair</code>? (I'm copying syntax from an example that I don't understand.)
  <li> I would ideally use <code>std::count</code> to calculate the number of elements of age <code>partnerAge</code> that are eligible (return <code>false</code> to <code>Host::isPaired()</code>). What is the syntax for extracting the sorted index that meets these requirements?
  </ol>
  
  <p>I'm obviously still learning C++ syntax. Thanks in advance for any help.</p>