bers
bers

Reputation: 5803

How can I get a std::mem_fn for std::set<int>::contains?

I seem to have a particular problem getting a std::mem_fn for std::set<int>::contains:

While the same works fine for my_class<int>::contains, a function similar (or identical?), it does not work for the one I actual want.

#include <functional>
#include <set>

template<class T>
struct my_class {
    bool contains(T) { return false; }
};

int main() {
    auto foo = std::mem_fn(&my_class<int>::contains);
    auto bar = std::mem_fn(&std::set<int>::contains);
}

Why, and how can I fix this?

(I am aware I can use wrapper functions or lambdas, but I am interested in specific notation to write it without those.)

Upvotes: 0

Views: 42

Answers (0)

Related Questions