Skip to content

Instantly share code, notes, and snippets.

@zao
Created December 2, 2014 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zao/eddc2ea7ecc4109eed9f to your computer and use it in GitHub Desktop.
Save zao/eddc2ea7ecc4109eed9f to your computer and use it in GitHub Desktop.
Function resolution in bind
#include <functional>
#include <string>
template <typename T>
bool fun(T, T, bool = 1, bool = 1) {
return true;
}
int main() {
std::string s;
std::bind(&fun<std::string>, std::placeholders::_1, s, false, true);
}
#include <functional>
#include <string>
template <typename T>
bool fun(T, T, bool = 1, bool = 1) {
return true;
}
int main() {
std::string s;
std::bind(fun<std::string>, std::placeholders::_1, s, false, true);
}
/*
$ icpc -std=c++11 ~/foo.cc
/home/l/lars/foo.cc(11): error: no instance of overloaded function "std::bind" matches the argument list
argument types are: (<unknown-type>, const std::_Placeholder<1>, std::string, bool, bool)
std::bind(fun<std::string>, std::placeholders::_1, s, false, true);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment