I have a template function, let's call it the "client":
template<typename T>
void client(T (*func)(const std::string&), const std::string& s) {}
Then there are a number of "adaptee" functions that all have an identical type of the first, non-default argument, but the following arguments vary in number and have default values:
void adaptee_one(const std::string&, int i = 1, char* c = nullptr) {}
void adaptee_two(const std::string&, float* f = nullptr) {}
The above functions are a given. Now what I want to do is to pass them to the above client<>()
function as the first parameter, and I only care about passing the first argument, const std::string&
. So I do the following:
void bindAdapteeOne(const std::string& s) {
return adaptee_one(s);
}
void bindAdapteeTwo(const std::string& s) {
return adaptee_two(s);
}
And then pass bindAdapteeX()
to client<>()
.
What I'd like to do is to automate the wrapping or have one (templated) wrapper instead of one per adaptee. I feel this might be the case for variadics, but have little idea about how to apply them exactly.
C++11 is fine, C++14 is fine if absolutely necessary.