Variadic template template parameters accept any template:
template
struct Test1 {
using type = int;
};
template
After some problems of my own, I came up with this solution which will work for any template class (also the ones you provide in your post).
The core of this solution is is_valid_specialization
which is used as the condition on whether or not the currying process may be considered complete:
#include
#include
template class C, typename... T>
struct is_valid_specialization {
typedef struct { char _; } yes;
typedef struct { yes _[2]; } no;
template class D>
static yes test(D*);
template class D>
static no test(...);
constexpr static bool value = (sizeof(test(0)) == sizeof(yes));
};
namespace detail {
template class BeCurry, bool = false, typename... S>
struct Currying {
template
using apply = Currying::value, S..., T...>;
};
template class BeCurry, typename... S>
struct Currying {
template
using apply = Currying::value, S..., T...>;
using type = typename BeCurry::type;
};
}
template class BeCurry>
using Currying = detail::Currying::value>;
template
struct Test1 { using type = int; };
template
struct Test2 { using type = char*; };
template
struct Test3 { using type = double; };
using curry = Currying;
using curry2 = Currying;
using curry3 = Currying;
template
void pretty_print(T) {
std::cout << __PRETTY_FUNCTION__ << std::endl;
}
int main() {
pretty_print(typename curry::apply::type{});
pretty_print(typename curry2::apply::apply::type{});
pretty_print(typename curry3::type{});
}
Output on ideone