Qt and C++0x lambdas: they don't seem to mix
Hello all,
I've been playing around with the experimental lambda branch of GCC, and I'm finding lambdas to be pretty handy to have. Well, that is, unless you are using members of the Qt framework's own template library. Let's take a look at a simple example:
Code:
#include <iostream>
#include <string>
#include <algorithm>
#include <QMap>
using namespace std;
int main()
{
QMap<int,string> my_map;
my_map[1] = "test";
my_map[2] = "lolololol";
for_each(my_map.begin(), my_map.end(), [](pair<int, string > test){ std::cout << test.second << "\n"; std::cout << test.first << "\n";});
return 0;
}
This code results in a bunch of errors. Replacing QMap with std::map makes this work. The errors are along the lines of "no match for call ‘(main()::<lambda>(std::pair<int, std::basic_string<char> >)) (std::basic_string<char>&)’
note: note: candidates are: main()::<lambda>(std::pair<int, std::basic_string<char> >)
This isn't a problem for me, but for others, it might be. So I thought I'd point it out.