I am trying to find a way to get this function into a more generic one.
void addStage(Image (f)(Image));
The thing i want to get is something that can recieve different types of functions with or without parameters, void or not.
I have tried something like this but of course it is not working.
void addStage(auto (f)(auto));
For giving more context I will say that this functions are going to be stages from a pipeline.
template <typename AnyFunction>
void addStage(AnyFunction f) {
// implement in header file!
}
Use SFINAE:
template<class T>
std::enable_if_t<std::is_function_v<T>, void> addStage(T* f) {
...
}
But, if you don't need any special check (wether T
is a function or no) you can actually just use a template
and leave to the compiler all the checks:
template<class T>
void addStage(T f) {
...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.