How to prevent std::function to bool conversion in C++ function overloading?
such as
class Object final {
public:
Object(bool boolean) : type_(22) {} //#1
Object(const std::function<int(int*, int)> value) : type_(11) {} //#2
int rettype() { return type_; };
private:
int type_;
};
int Println(int *args, int nargs) {
printf("Println\n");
return 0;
}
int main() {
cout << Object(Println).rettype() << endl; // 22
cout << Object(std::function<int(int*, int)>(Println)).rettype() << endl; // 11
}
I want to call #2 through Object(Println) instead of Object(std::function<int(int*, int)>(Println)),but the result is that #1 is called
How should I achieve this?