I'm trying to implement bind function from boost library.
Below you can see the main struct bind_t with defined operator().
My question is as follows: Why should we specify in decltype in returning type of operator() returning type of call() explicitly as member function (if I remove this-> before call, the template argument deduction fails in g++.)
Also interesting, that using clang++ there's no such problem.
I have no idea, why this happens.
template <typename F, typename ... P>
struct bind_t {
private:
std::tuple<typename holder<P>::type...> p;
F func;
template <size_t ... N, typename ... Args>
auto call(index_list<N ...>, Args const& ... args) const -> decltype(func(std::get<N>(p)(args...)...)) {
return func(std::get<N>(p)(args...)...);
}
public:
bind_t(F f, P ... p):
p(std::move(p)...),
func(std::move(f))
{}
template <typename ... Args>
auto operator()(Args const& ... args) const -> decltype(this->call(typename indices_by_num<sizeof...(P)>::type(), args...)) {
typename indices_by_num<sizeof...(P)>::type indices;
return call(indices, args...);
}
};
full source of implementation
simple usecase