I believe the title describes my question well enough, but still I will an example:
std::string GraphFunction(std::function<std::vector<float>(float)>function, FunctionGraphingParameters graphParams = FunctionGraphingParameters());
std::string GraphFunction(std::vector<float>(*function)(float), FunctionGraphingParameters graphParams = FunctionGraphingParameters());
std::string GraphFunction(float (*function)(float), FunctionGraphingParameters graphParams = FunctionGraphingParameters());
Where fisrt overload does all the hard work, while others adapt parameters and just call first one.
For context here’s the implementation for wrapper functions:
std::string GraphFunction(std::vector<float>(*function)(float), FunctionGraphingParameters graphParams)
{
std::function<std::vector<float>(float)> adaptedFunction = [=](float x) -> std::vector<float> {return std::vector<float>{function(x)};};
return GraphFunction(adaptedFunction, graphParams);
}
std::string GraphFunction(float (*function)(float), FunctionGraphingParameters graphParams)
{
std::function<std::vector<float>(float)> adaptedFunction = [=](float x) -> std::vector<float> {return std::vector<float>{function(x)};};
return GraphFunction(adaptedFunction, graphParams);
}
``