template class class indirect_fun public explicit indirect_fun const f

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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_;
};