vendredi 2 juin 2017

How to use "using" keyword for variadic template

I have a variadic template class that can take any number of variables in the constructor and also a std::tuple/std::pair and so forth. I would like to use this wrapper for functions with varying return types. for example

class f1
{
using output= double;
output operator(){do_smth};
}
class f2
{
using output= std::tuple<double,int>;
output operator(){do_smth};
}



template <typename... Types>
class OutputType
{
    std::tuple<Types...> m_val;

public:
    OutputType(std::tuple<Types...>&& val) : m_val(val) {};
    OutputType(Types&& ... val) : m_val(std::forward<Types>(Types)...) {};

};

Now in a third class I would like to declare using like this

template <typename F>
class dummy
{
using Output = typename OutputType(typename F::Output));
}

how do I declare the above using statement so it does the correct thing also for dummy<f2>. (i.e OutputType<double,int> and not OutputType<std::tuple<double,int>>)

Aucun commentaire:

Enregistrer un commentaire