title: Boost Variant : How can I do a visitor that returns the type that was set?
body: <p>I'm trying to write a generic map that uses a boost:variant as the value.
  I'm stuck on trying to write the get(std::string key) function that will return the appropriate type.</p>
  
  <p>Here is what I came up with so far:</p>
  
  <pre><code> class GenericHashMap {
  private:
  std::map&lt; std::string, boost::variant&lt;int, bool, double, std::string&gt; &gt; genericMap;
  
  public:
    template&lt;typename T&gt;
    bool getValue(const std::string &amp; key, T &amp; value) {
       if ( _map.find(key) == _map.end() ) {
          return false;
       }
       T * valuePtr = boost::get&lt;T&gt;(_map[key]);
       if (valuePtr == NULL) {
          return false;
       }
       value = *valuePtr;
       return true;
    }
  }
  </code></pre>
  
  <p>I'm curious how I should handle iterators? Is it worth making my own nested iterators or just return the nested std::map.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I added the class design I was hoping to achieve (i.e. a generic hashmap). The problem I had was that I wanted a way for the user to query if for a specific key it was stored as a specific type.</p>