Augenblick zurückkehren, ich habe folgendes gelten zwei Funktionen auf einen Wert und gibt eine 2-Werttupel:ein Tupel von Funktionen auf einen Wert Nehmen und ein Tupel
template<typename F1, typename F2>
class Apply2
{
public:
using return_type = std::tuple<typename F1::return_type, typename F2::return_type>;
Apply2(const F1& f1, const F2& f2) : f1_(f1), f2_(f2) {}
template<typename T> return_type operator()(const T& t) const
{
return std::make_tuple(f1_(t), f2_(t));
}
protected:
const F1& f1_;
const F2& f2_;
};
ich dies verallgemeinern wollte N Funktionen:
template<typename ...F>
class ApplyN
{
public:
using return_type = std::tuple<typename F::return_type...>;
ApplyN(const std::tuple<F...>& fs) : functions_(fs) {}
template<typename T> return_type operator()(const T& t) const
{
return ???;
}
protected:
std::tuple<F...> functions_;
};
ich weiß, dass ich wohl irgendwie Vorlage Rekursion verwenden müssen, aber ich kann meinen Kopf um es nicht wickeln. Irgendwelche Ideen?
Noch ein Job für Superman! Ähm, ich meine, für [Indizes] (http://stackoverflow.com/a/10930078/46642). –