template with more than one tuple parameter

Zhenya zheny at list.ru
Sat Jul 28 09:17:14 PDT 2012


Why do not D allow templates with more than one tuple
parameters,at the
same time that C++11 support it:

namespace
{
template <class R,unsigned int N>
struct Apply_Helper
{
	template<typename F, typename... ArgsT, typename... Args>
	static R apply(const F& f, const std::tuple<ArgsT...>& t,
Args&... args) {
	return Apply_Helper<R,N-1>::apply(f, t, std::get<N-1>(t),
args...);
	}
};

template <class R>
struct Apply_Helper<R,0>
{
	template<typename F, typename... ArgsT, typename... Args>
	static R apply(const F& f, const std::tuple<ArgsT...>&, Args&...
args) {
		return f(args...);
	}
};

template <typename R, typename... ArgsT>
R apply(const std::function<R(ArgsT...)>& f,
std::tuple<ArgsT...>& t)
{
	return Apply_Helper<R,sizeof...(ArgsT)>::apply(f, t);
}
this code compiles in gcc 4.6.1


More information about the Digitalmars-d-learn mailing list