Feb 8, 2015

[C++11] variadic parameter deduse

#include <iostream>
using namespace std;


template<typename, typename>
struct FunType
{
    void fun()
    {
        cout << "fun" << endl;
    }
};


template<typename ...T, template<typename...> class ITYPE>
void usage(ITYPE<T...>& in, T... t) // type deduce is evaluated with order left -> right
{
    in.fun();
}


int main()
{
    FunType<int,double> f;
    usage(f,1,2.0);
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.