Context
In mathematics-related context, I'd like to define functors working on <cmath>
functions. For the purpose of this question, we will be using std::invoke
as our functor.
This is ill-formed (live demo):
std::invoke(std::sin, 0.0);
(g++-8.1) error: no matching function for call to 'invoke(<unresolved overloaded function type>, double)'
Indeed, std::sin
is an overload set and the compiler lacks the type information to choose one of those functions.
Question
How could I name a specific function from an overload set? With what could we replace LEFT
and RIGHT
so that the following is well-formed and does what is expected (say, select double std::sin(double)
)?
#include <functional>
#include <cmath>
int main()
{
(void) std::invoke(LEFT std::sin RIGHT, 0.0);
}
If this is not possible, is there a way to define a functor so it is overload-set-aware?