Created
December 2, 2014 14:09
-
-
Save zao/eddc2ea7ecc4109eed9f to your computer and use it in GitHub Desktop.
Function resolution in bind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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