Variadic template template parameters accept any template:
template
struct Test1 {
using type = int;
};
template
Simple solution is:
template
<
template class BeCurry,
typename... Params
>
struct Currying
{
template
using curried = BeCurry;
template
using type = typename curried::type;
template
using apply = Currying;
};
But it does not work with templates like Test1
and Test2
due to compilation errors (under gcc, at least). A workaround for this problem looks like this:
template
<
template class BeCurry,
typename... Params
>
struct Curry
{
using type = BeCurry;
};
template
<
template class BeCurry
>
struct Curry
{
using type = BeCurry<>;
};
And now lines
template
using curried = BeCurry;
should be replaced with lines
template
using curried = typename Curry::type;
Example of using:
#include
#include
template
void print_type(T t)
{
std::cout << typeid(t).name() << std::endl;
}
// ...
print_type(Currying::type{});
print_type(Currying::apply::type<>{});
print_type(Currying::type{});
print_type(Currying::apply::type{});
print_type(Currying::apply::apply::type<>{});
print_type(Currying::apply::type<>{});
Full example at ideone.