title: C++: Call of overloaded ‘basic_string()’ is ambiguous
body: <p>I have to post you my code because I can't get out on why I get this error!<br>
  I know I could have use templates..</p>
  
  <pre><code>class Mappable {
      typedef boost::variant&lt;int, bool, unsigned short, float, char, timeval,
              double, std::string, size_t&gt; MultiType;
  private:
      class Handler {
          friend class Mappable;
      public:
          template&lt;typename T&gt;
          operator T&amp;() {
              T t = 0;
              try {
                  t = boost::get&lt;T&gt;(it);
              } catch (...) {
              }
              return t;
          }
          template&lt;class T&gt;
          Handler&amp; operator=(const T&amp; rhs) {
              it = rhs;
              return *this;
          }
      private:
          Handler(MultiType&amp; it, const std::string&amp; key);
          MultiType&amp; it;
      };
  public:
      Mappable(const std::string&amp; tableName);
      virtual ~Mappable();
      Handler operator[](const std::string&amp; key) {
          return Handler(map_[key], key);
      }
      std::string keyTypeToString(const std::string&amp; key) {
          std::stringstream ss;
          ss &lt;&lt; boost::get&lt;T&gt;(map_[key]);
          return ss.str();
      }
  private:
      typedef std::map&lt;std::string, MultiType&gt; MultiTypeMap;
      std::string valueFromKey(const MultiTypeMap::iterator&amp; it);
      template&lt;class T&gt; 
      MultiTypeMap map_;
  };
  
  /* Main.cpp */
  
  int main() {
     Mappable m;
     m["x"] = 2;
     m["data"] = "my data string value"; /* Correctly works */
     cout &lt;&lt; (int)(m["x"]); /* Correctly works */
     cout &lt;&lt; (string)(m["data"]); /* Error */
     cout &lt;&lt; m.keyTypeToString&lt;string&gt;("data"); /* Correctly works */
  }
  </code></pre>
  
  <p>Error are:</p>
  
  <pre><code>../src/data/Mappable.h:98:41: error: call of overloaded ‘basic_string(Mappable::Handler)’ is ambiguous
  ../src/data/Mappable.h:98:41: note: candidates are:
  /usr/include/c++/4.6/bits/basic_string.tcc:214:5: note: std::basic_string&lt;_CharT, _Traits, _Alloc&gt;::basic_string(const _CharT*, const _Alloc&amp;) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;, _Alloc = std::allocator&lt;char&gt;]
  /usr/include/c++/4.6/bits/basic_string.tcc:171:5: note: std::basic_string&lt;_CharT, _Traits, _Alloc&gt;::basic_string(const std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;, _Alloc = std::allocator&lt;char&gt;, std::basic_string&lt;_CharT, _Traits, _Alloc&gt; = std::basic_string&lt;char&gt;]
  /usr/include/c++/4.6/bits/basic_string.tcc:179:5: note: std::basic_string&lt;_CharT, _Traits, _Alloc&gt;::basic_string(const _Alloc&amp;) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;, _Alloc = std::allocator&lt;char&gt;]
  </code></pre>
  
  <p>I can't understand where is ambiguity!</p>