Is it possible to transform the types in a parameter pack?

c++, c++11, metaprogramming, templates

Solution

Yes we can do that

template<template<typename...> class List, 
         template<typename> class Mod, 
         typename ...Args>
struct magic {
    typedef List<typename Mod<Args>::type...> type;
};

Problem

Is it possible to transform the types of a parameter pack and pass it on? E.g. given the following: ``` template<class... Args> struct X {}; template<class T> struct make_pointer { typedef T* type; }; template<class T> struct make_pointer<T*> { typedef T* type; }; ``` Can we define a template `magic` or something similar so that the following assertion holds: ``` typedef magic<X, make_pointer, int, char>::type A; typedef X<int*, char*> B; static_assert(is_same<A, B>::value, ":("); ```

Original source