title: Can not convert typedef to std::pair in Visual Studio 2015
body: <p>I try to upgrade some projects from <code>Visual Studio 2010</code> to <code>2015</code>. In <code>2010</code> everything works fine, but in <code>2015</code> I get compiler errors which I don't really understand.</p>
  
  <p>I condensed the code into an SSCCE</p>
  
  <pre><code>#define _CRT_SECURE_NO_WARNINGS
  
  #include &lt;iostream&gt;
  #include &lt;algorithm&gt;
  #include &lt;set&gt;
  #include &lt;map&gt;
  #include &lt;vector&gt;
  #include &lt;ctime&gt;
  #include &lt;cstdlib&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  
  #define UNUSED(x) (void(x))
  
  class ColumnDef
  {
  public:
  };
  
  class XMLColumnDef
  {
  public:
      typedef std::pair&lt;std::string, XMLColumnDef&gt; pair;
      typedef std::pair&lt;std::string, XMLColumnDef *&gt; ptr_pair;
  
  public:
      // Move constructor for moving the column into an container
      // without destroying it. Note that the source is no longer valid after 
      // such a move.
      XMLColumnDef(XMLColumnDef &amp;oSource)
      {
          mColumn = oSource.mColumn;
          oSource.mColumn = NULL;
      }
  
      XMLColumnDef(ColumnDef *pColumn)
      {
          mColumn = pColumn;
      }
  
      virtual ~XMLColumnDef(void)
      {
          delete mColumn;
      }
  
  private:
      ColumnDef *mColumn;
  };
  
  class XMLNodeObserver
  {
  public:
      typedef std::map&lt;std::string, XMLNodeObserver *&gt; map;
      typedef std::pair&lt;std::string, XMLNodeObserver *&gt; pair;
      typedef std::map&lt;std::string, XMLColumnDef&gt; row_def;
  
  public:
      XMLNodeObserver(void) {}
      virtual ~XMLNodeObserver(void) {};
  
      void addObserver(XMLNodeObserver::map &amp;oNodeObserver, std::string const &amp;oPath, XMLNodeObserver *oObserver = NULL)
      {
          UNUSED(oNodeObserver);
          UNUSED(oPath);
          UNUSED(oObserver);
      }
      void addColumnDef(XMLNodeObserver::map &amp;oNodeObserver, std::string const &amp;oPath, ColumnDef *oColumn, XMLNodeObserver *oObserver = NULL)
      {
          if (oObserver == NULL)
              oObserver = this;
  
          addObserver(oNodeObserver, oPath, oObserver);
  
          XMLColumnDef::pair pr = std::make_pair(oPath, XMLColumnDef(oColumn));
  
          if (oObserver-&gt;mColumnDefs.find(oPath) != oObserver-&gt;mColumnDefs.end())
          {
              // If a node already exists, we report an internal error, because this indicates a program bug and should be fixed.
              std::cerr &lt;&lt; "INTERNAL ERROR: Duplicate rowdef key in XML node observer: " &lt;&lt; oPath &lt;&lt; std::endl;
          }
          oObserver-&gt;mColumnDefs.insert(pr);
      }
  
  private:
      row_def mColumnDefs;
      bool mDebugMode;
  };
  
  int main()
  {
      XMLNodeObserver o;
      XMLNodeObserver::map om;
  
      o.addColumnDef(om, "/testpath", new ColumnDef());
  
      std::cout &lt;&lt; "\nDone! Press any key..." &lt;&lt; std::endl;
      std::cin.ignore();
  
      return 0;
  }
  </code></pre>
  
  <p>The error I get in this line:</p>
  
  <pre><code>oObserver-&gt;mColumnDefs.insert(pr);
  </code></pre>
  
  <p>The error I get is this:</p>
  
  <pre><code>junk.cpp(104): error C2664: 'void std::_Tree&lt;std::_Tmap_traits&lt;_Kty,_Ty,_Pr,_Alloc,false&gt;&gt;::insert(std::initializer_list&lt;std::pair&lt;const _Kty,_Ty&gt;&gt;)': cannot convert argument 1 from 'XMLColumnDef::pair' to 'std::pair&lt;const _Kty,_Ty&gt; &amp;&amp;'
            with
            [
                _Kty=std::string,
                _Ty=XMLColumnDef,
                _Pr=std::less&lt;std::string&gt;,
                _Alloc=std::allocator&lt;std::pair&lt;const std::string,XMLColumnDef&gt;&gt;
            ]
            and
            [
                _Kty=std::string,
                _Ty=XMLColumnDef
            ]
  junk.cpp(104): note: Reason: cannot convert from 'XMLColumnDef::pair' to 'std::pair&lt;const _Kty,_Ty&gt;'
            with
            [
                _Kty=std::string,
                _Ty=XMLColumnDef
            ]
  junk.cpp(104): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
  </code></pre>
  
  <p>It looks as if <code>Visual Studio 2015</code> doesn't like it that the parameter <code>oPath</code> is <code>const &amp;</code> but that shouldn't matter as it should be assigned to the <code>pair</code> member.</p>
  
  <p>I also removed the <code>typedefs</code> and tried to compile it with the long names, but that doesn't seem to be the problem (and shouldn't anyway) because I get the same error.</p>
  
  <p>Like:</p>
  
  <pre><code>std::pair&lt;std::string, XMLColumnDef&gt; pr = std::pair&lt;std::string, XMLColumnDef&gt;(oPath, XMLColumnDef(oColumn));
  </code></pre>