title: Retrieve values from data structure holding variant data types without specifying the return type
body: <p>I am currently using a map with string data type as key and a variant value. I am relying on the boost::variant library for defining the map data type. I am currently following a few tutorial on boost::variant for extracting the values from the map without having to specifying the exact data type value I want to retrieve while iterating through it.
  source: <a href="https://theboostcpplibraries.com/boost.variant" rel="nofollow noreferrer">https://theboostcpplibraries.com/boost.variant</a>
  I want something like the last example for generic data type but instead of printing the values I was to return them.
  The following below does not seem to be working correctly.</p>
  
  <pre><code>struct output : public boost::static_visitor&lt;&gt;
  {
    template &lt;typename T&gt;
    T operator()(T t) const { return t }
  };
  </code></pre>
  
  <p>I also instantiate a map while populating it with a string data type as keys and boost::variant type as values; and later on iterate through the map and process the values.</p>
  
  <pre><code>std::map&lt;std::string,boost::variant&lt;int, double, long long, std::string&gt;&gt; _keyPairValue;
  
  for(auto &amp;x: _keyPairValue)
  {
    // appending a key pair value to a bson object which is part of mongo sdk
    b &lt;&lt; x.first &lt;&lt; boost::apply_visitor(output{},x.second);
  }
  </code></pre>