template<class T> class indirect_fun {
public:
explicit indirect_fun(const T& fun): fun_(fun) {}
indirect_fun() = default;
indirect_fun(const indirect_fun<T>&) = default;
indirect_fun(indirect_fun<T>&&) = default;
indirect_fun<T>& operator=(const indirect_fun<T>&) = default;
indirect_fun<T>& operator=(indirect_fun<T>&&) = default;
template<class... Args> auto operator() (Args&&... args) -> decltype(this->fun_((*args)...)) {
return fun_((*args)...);
}
template<class... Args> auto operator() (Args&&... args) const -> decltype(this->fun_((*args)...)) {
return fun_((*args)...);
}
private:
T fun_;
};