Incorrect Overload Resolution - by WorkingHorse

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 606746 Comments
Status Closed Workarounds
Type Bug Repros 2
Opened 9/29/2010 11:13:57 AM
Access Restriction Public


The C++ compiler cannot match the correct overload for the std::transform template in the algorithm library -- this is just one example, there are no doubt others where code that used to work in Visual Studio 2005 no longer works in 2010.
Sign in to post a comment.
Posted by Stephan [MSFT] on 2/16/2011 at 8:11 PM

Thanks for reporting this bug. We've fixed it, and the fix will be available in VC11. Note that due to changes between C++98/03 and C++0x, you'll have to use either make_pair<string&, string&> or make_pair<const string&, const string&>. Here's an example:

C:\Temp>type meow.cpp
#include <algorithm>
#include <iostream>
#include <iterator>
#include <map>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

void print(const map<string, string>& m) {
    for (auto i = m.begin(); i != m.end(); ++i) {
        cout << "(" << i->first << ", " << i->second << ")" << endl;

int main() {
    vector<string> series;

    vector<string> captains;

    map<string, string> m;

    transform(series.begin(), series.end(), captains.begin(), inserter(m, m.end()), make_pair<string&, string&>);


    cout << "-----" << endl;

    const vector<string> vs = series;
    const vector<string> vc = captains;

    transform(vc.begin(), vc.end(), vs.begin(), inserter(m, m.end()), make_pair<const string&, const string&>);


C:\Temp>cl /EHsc /nologo /W4 meow.cpp

(DS9, Sisko)
(ENT, Archer)
(TNG, Picard)
(TOS, Kirk)
(VOY, Janeway)
(Archer, ENT)
(Janeway, VOY)
(Kirk, TOS)
(Picard, TNG)
(Sisko, DS9)

Also, please note that the STL's headers include each other in unspecified ways, so you should always be careful to include the headers that you need (e.g. <string> for string and <utility> for make_pair).

If you have any further questions, feel free to E-mail me at .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Helen [MSFT] on 9/29/2010 at 7:44 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will

follow-up with your issue.

Posted by Microsoft on 9/29/2010 at 6:23 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(