3 ms·
std::function has runtime overhead, though. Maybe you’d prefer a type alias with the same syntax as std::function? template<class F> struct func_ {};
by evincarofautumn 12y ago
std::function has runtime overhead, though. Maybe you’d prefer a type alias with the same syntax as std::function?
template<class F>
struct func_ {};
template<class Result, class... Args>
struct func_<Result(Args...)> {
typedef Result(*type)(Args...);
};
template<class F>
using func = typename func_<F>::type;
func<func<void(int)>(int, func<void(int)>)> signal;
- MereInterest 12y agoOoh, I hadn't thought of that. I will generally use a templated form if I care about the runtime overhead, or a std::function if I want to support multiple types of callables within the same container, and so I don't use raw function pointers very often.
- evincarofautumn 12y agoBy the way, I’m an idiot. template<class T> using ptr = T*; ptr<ptr<void(int)>(int, ptr<void(int)>)> signal; :)