This code uses the auto keyword which is nothing special, the rest is a lambda function. The closest thing in this case would be to replace it with a functor.
Please help me in me rewriting the code in a C++ version previous to 0x.
It's better to understand it. People will get tired of rewriting code for you.
You have a lambda expression assigned to the __greater variable. Auto means its type is deducted by the compiler so you don't have to bother. You can use __greater whenever you used a function object before. So in principle the lambda expression defines a function object.
The lambda expression itself uses (captures) the scene variable by reference so it won't get copied. It takes two variables (by const reference) of the connect_line type as parameters. It compares two scene positions and determines whether the first is greater than the second. The bool return type is deducted automatically.
Last edited by nuzzle; July 31st, 2011 at 05:27 AM.
Bookmarks