I’m trying to save a nested lambda function in Visual Studio 2012.
class Wrap
{
public:
typedef function<void(Wrap*)> Method;
Method method;
std::map<string, Wrap> methods;
};
Wrap x;
x.method = [](Wrap *arg) {
Wrap::Method t = [](Wrap*) {};
arg->methods["child"].method = t;
};
Which produces this error:
error C2678: binary
'<': no operator found which takes a left-hand operand of typeconst std::string(or there is no acceptable conversion)
I can’t make heads or tails of this error.
I have tested this in g++ and clang. They can compile it.
http://liveworkspace.org/code/4kVlUY$72
How would i make Visual Studio to compile it? Any workaround?
The problem is completely unrelated to what you expect:
solves it. Seems like the comparison operators require
<string>to be included explicitly, while the class itself is defined if you include just<map>.