I'm hoping to build a std::map of lambdas with varying signatures. E.g., this works:
std::map<std::string, std::function<bool(double)>> map;
map.emplace("gt_zero", [](double a) { return a > 0; });
map.emplace("lt_zero", [](double a) { return a < 0; });
bool foo = map["gt_zero"](42); // returns true
bool bar = map["lt_zero"](42); // returns false
Below demonstrates what I'd also like to do in the same map, but it won't compile because the lambda signature doesn't match the map's:
map.emplace("equal", [](double a, double b) { return a == b; });
bool baz = map["equal"](42, 42);
Is there a way to define a std::map to accept lamdbas with different signatures?
EDIT: The above does not approximate my use case. It's for identifying my coding issue. The actual use case has knowledge of the signature.
EDIT: Thanks to the posters that pointed out the similar question Store functions with different signatures in a map. Unfortunately, the code posted in that answer does not compile for VS2017/C++17.