#include <iostream>
#include <vector>
template<class iterator>
void test(iterator, iterator)
{
std::cout << "test iterator\n";
}
template<class iterator, class predicate>
void test(iterator, iterator, predicate)
{
std::cout << "test iterator, predicate\n";
}
template<class container, class predicate>
void test(const container& cont, predicate compare)
{
std::cout << "test container, predicate\n";
test(cont.begin(), cont.end(), compare);
}
template<class container>
class adapter
{
public:
typedef typename container::iterator iterator;
adapter(container* cont) : cont(cont)
{ }
iterator begin() const
{ return cont->begin(); }
iterator end() const
{ return cont->end(); }
bool operator()(const iterator& one, const iterator& two)
{ return *one < *two; }
private:
container* cont;
};
int main()
{
std::vector<int> v;
adapter<std::vector<int>> a(&v);
test(a, a);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKdGVtcGxhdGU8Y2xhc3MgaXRlcmF0b3I+CnZvaWQgdGVzdChpdGVyYXRvciwgaXRlcmF0b3IpCnsKICAgc3RkOjpjb3V0IDw8ICJ0ZXN0IGl0ZXJhdG9yXG4iOwp9Cgp0ZW1wbGF0ZTxjbGFzcyBpdGVyYXRvciwgY2xhc3MgcHJlZGljYXRlPgp2b2lkIHRlc3QoaXRlcmF0b3IsIGl0ZXJhdG9yLCBwcmVkaWNhdGUpCnsKICAgc3RkOjpjb3V0IDw8ICJ0ZXN0IGl0ZXJhdG9yLCBwcmVkaWNhdGVcbiI7Cn0KCnRlbXBsYXRlPGNsYXNzIGNvbnRhaW5lciwgY2xhc3MgcHJlZGljYXRlPgp2b2lkIHRlc3QoY29uc3QgY29udGFpbmVyJiBjb250LCBwcmVkaWNhdGUgY29tcGFyZSkKewogICBzdGQ6OmNvdXQgPDwgInRlc3QgY29udGFpbmVyLCBwcmVkaWNhdGVcbiI7CgogICB0ZXN0KGNvbnQuYmVnaW4oKSwgY29udC5lbmQoKSwgY29tcGFyZSk7Cn0KCnRlbXBsYXRlPGNsYXNzIGNvbnRhaW5lcj4KY2xhc3MgYWRhcHRlcgp7CnB1YmxpYzoKICAgdHlwZW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