#include <iostream>
#include <functional>
template <typename T> struct MinHeap
{
std::function<bool(T, T)> less;
MinHeap(const std::function<bool(T, T)>& cmp) : less(cmp)
{
// ...
}
};
int main()
{
MinHeap<int> yoba([](int a, int b) { return (a % 2 == 1 && b % 2 == 0) || (a % 2 == b % 2 && a < b); });
std::cout << yoba.less(1, 2) << ' '
<< yoba.less(7, 2) << ' '
<< yoba.less(6, 2) << ' '
<< yoba.less(6, 9) << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KCgp0ZW1wbGF0ZSA8dHlwZW5hbWUgVD4gc3RydWN0IE1pbkhlYXAKewoJc3RkOjpmdW5jdGlvbjxib29sKFQsIFQpPiBsZXNzOwoKCU1pbkhlYXAoY29uc3Qgc3RkOjpmdW5jdGlvbjxib29sKFQsIFQpPiYgY21wKSA6IGxlc3MoY21wKQoJewoJCS8vIC4uLgoJfQp9OwoKCmludCBtYWluKCkKewoJTWluSGVhcDxpbnQ+IHlvYmEoW10oaW50IGEsIGludCBiKSB7IHJldHVybiAoYSAlIDIgPT0gMSAmJiBiICUgMiA9PSAwKSB8fCAoYSAlIDIgPT0gYiAlIDIgJiYgYSA8IGIpOyB9KTsKCXN0ZDo6Y291dCA8PCB5b2JhLmxlc3MoMSwgMikgPDwgJyAnCgkgICAgICAgICAgPDwgeW9iYS5sZXNzKDcsIDIpIDw8ICcgJwoJICAgICAgICAgIDw8IHlvYmEubGVzcyg2LCAyKSA8PCAnICcKCSAgICAgICAgICA8PCB5b2JhLmxlc3MoNiwgOSkgPDwgc3RkOjplbmRsOwoJcmV0dXJuIDA7Cn0=