Skip to content

Instantly share code, notes, and snippets.

@pozdneev
Last active May 5, 2021 20:02
Show Gist options
  • Save pozdneev/c98135fa9e75c9b3f8e31355d5f03a3d to your computer and use it in GitHub Desktop.
Save pozdneev/c98135fa9e75c9b3f8e31355d5f03a3d to your computer and use it in GitHub Desktop.
mem_fn: unresolved overloaded function type
// g++ -std=c++14 -c mem_fn.cpp
//
// error: no matching function for call to ‘mem_fn(<unresolved overloaded function type>)’
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
struct A {
int& getAttribute();
const int& getAttribute() const;
};
vector<int> foo(const vector<A>& as) {
vector<int> is;
transform(as.begin(), as.end(), back_inserter(is), mem_fn(&A::getAttribute));
return is;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment