title: error: cannot bind non-const lvalue reference of type ** to an rvalue of type **
body: <p>I am working on compiling some old api code that was written back in mid to late 90's, it is written in C++98 and I am using GCC on linux.</p>
  <p>I have this line of offending code:</p>
  <pre><code>UnpackCommunityData(data.insert(std::map&lt;long, CommunityData&gt;::value_type(ReadLong(), CommunityData())).first);
  </code></pre>
  <p>The above line leads to this error:</p>
  <pre><code>msg/Profile/SMsgProfileMsgs.cpp: In member function ‘virtual void WONMsg::SMsgProfile2DownloadCommunityTreeReply::Unpack()’:
  msg/Profile/SMsgProfileMsgs.cpp:1410:107: error: cannot bind non-const lvalue reference of type ‘std::map&lt;long int, WONMsg::CommunityData&gt;::iterator&amp;’ {aka ‘std::_Rb_tree_iterator&lt;std::pair&lt;const long int, WONMsg::CommunityData&gt; &gt;&amp;’} to an rvalue of type ‘std::_Rb_tree_iterator&lt;std::pair&lt;const long int, WONMsg::CommunityData&gt; &gt;’
  UnpackCommunityData(data.insert(std::map&lt;long, CommunityData&gt;::value_type(ReadLong(), CommunityData())).first);
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
  </code></pre>
  <p>These are the definitions:</p>
  <pre><code>    struct CommunityData {
       long CommunitySeq;
       long TrustLevelId;
       std::wstring Name;
       std::wstring Descr;
       long JoinByInvitationOnly;
       long ParentCommunitySeq;
       std::vector&lt;long&gt; ChildrenSeq;
      };
      std::map&lt;long, CommunityData&gt;           data;
      void UnpackCommunityData(std::map&lt;long, CommunityData&gt;::iterator&amp;);
  
  void SMsgProfile2DownloadCommunityTreeReply::UnpackCommunityData(std::map&lt;long, CommunityData&gt;::iterator&amp; itInfo) {
      itInfo-&gt;second.CommunitySeq = itInfo-&gt;first;
      itInfo-&gt;second.TrustLevelId = ReadLong();
      ReadWString(itInfo-&gt;second.Name);
      ReadWString(itInfo-&gt;second.Descr);
      itInfo-&gt;second.JoinByInvitationOnly = ReadLong();
      itInfo-&gt;second.ParentCommunitySeq = ReadLong();
  
      unsigned short n = ReadShort();
      for (int i = 0; i &lt; n; ++i) itInfo-&gt;second.ChildrenSeq.push_back(ReadLong());
  
      databyname.insert(std::map&lt;std::wstring, long&gt;::value_type(itInfo-&gt;second.Name, itInfo-&gt;second.CommunitySeq));
  }
  </code></pre>
  <p>I'm not well versed in templates in C++, so I do not have a clue as to how to fix this error.</p>
  <p>I would like it if someone could walk me through the error and solution.</p>