#include <vector>
#include <set>
#include <algorithm>
#include <functional>
struct point // A simple custom point structure
{
int x, y;
};
// Functor created by the wizard
// --------------------------------------------------
struct point_functor
: public std::binary_function<point, point, bool>
{
bool operator() (const point &left, const point &right) const
{
if (left.x == right.x)
return (left.y < right.y);
else
return (left.x < right.x);
}
};
// --------------------------------------------------
int main()
{
std::vector<point> v;
std::sort(v.begin(), v.end(), point_functor()); //Compiles happily with point structures
std::set<point, point_functor> s;
s.find(point()); //Compiles happily with point structures
return 0;
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHNldD4KCiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxmdW5jdGlvbmFsPgoKc3RydWN0IHBvaW50IC8vIEEgc2ltcGxlIGN1c3RvbSBwb2ludCBzdHJ1Y3R1cmUKewogICAgaW50IHgsIHk7Cn07CgovLyBGdW5jdG9yIGNyZWF0ZWQgYnkgdGhlIHdpemFyZAovLyAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQoKc3RydWN0IHBvaW50X2Z1bmN0b3IKCTogcHVibGljIHN0ZDo6YmluYXJ5X2Z1bmN0aW9uPHBvaW50LCBwb2ludCwgYm9vbD4KewoJYm9vbCBvcGVyYXRvcigpIChjb25zdCBwb2ludCAmbGVmdCwgY29uc3QgcG9pbnQgJnJpZ2h0KSBjb25zdAoJewoJCWlmIChsZWZ0LnggPT0gcmlnaHQueCkKCQkJcmV0dXJuIChsZWZ0LnkgPCByaWdodC55KTsKCQllbHNlCgkJCXJldHVybiAobGVmdC54IDwgcmlnaHQueCk7Cgl9Cn07CgovLyAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQoJCmludCBtYWluKCkKewoJc3RkOjp2ZWN0b3I8cG9pbnQ+IHY7CglzdGQ6OnNvcnQodi5iZWdpbigpLCB2LmVuZCgpLCBwb2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