ich einen solchen Code haben, die gut funktioniert:Warum Code mit lokalen Struktur als Parameter für die STL-Funktion nicht in g ++ kompilieren?
#include <algorithm>
#include <iostream>
char x[11]= "ABCDEFGHIJ";
char y[11];
struct F {
char operator() (char c) const
{ return c+1; }
};
int main()
{
std::transform(x, x+10, y, F());
y[10] = 0; std::cout <<y <<std::endl;
}
Aber wenn ich es auf diese Art zu ändern:
#include <algorithm>
#include <iostream>
char x[11]= "ABCDEFGHIJ";
char y[11];
int main()
{
struct F {
char operator() (char c) const
{ return c+1; }
};
std::transform(x, x+10, y, F());
y[10] = 0; std::cout <<y <<std::endl;
}
Es wird nicht kompilieren, sagen:
error: no matching function for call to ‘transform(char [11], char*, char [11], main()::F)’
Was ist los?
GCC-Version ist 4.4, die Lambda-Ausdrücke nicht erkennt.
kompilieren Sie wie C++ 03 oder C++ 0x? –