Reputation: 1291
I'm trying to use the standard std::function
with custom overloaded operators. However applying std::logical_and
to my Test
class with a string
parameter is not working in this situation.
class Test {
public:
std::string value;
Test(std::string cvalue) : value(cvalue) {}
std::string operator&& (const std::string& rhs) const {
if (rhs == value) {
return "true";
}
return "false";
}
};
int main() {
Test test("hey");
std::string out = std::logical_and<std::string>()(test, "hey");
std::cout << out << std::endl;
return 0;
}
What is the proper way of achieving this? My expected output is "true"
Upvotes: 0
Views: 64