I am trying to generate a type that is using template-of-templates using boost::hana but ran into trouble.
I have the following classes
template<template<typename> typename BarModel>
struct Foo {
BarModel<double> bar;
}
template<typename T>
struct BarOne {
T x;
}
template<typename T>
struct BarTwo {
T y;
}
I now want to create a Foo<BarImpl>
for each of the BarX<T>
classes:
auto bar_types = hana::tuple_t<hana::template_t<BarOne>, hana::template_t<BarTwo>>;
hana::for_each(bar_types, [](auto t) {
auto footype = SOMETHING(t);
});
Problem, is I am not sure how this is supposed to be done. My first attempt was to do
using BarT = typename decltype(t)::type;
auto bar_t = BarT(); // template_t, can create BarX<T> classes
auto foo_t = hana::template_<Foo>; // <-- FAIL
auto foo_bar_t = foo_t(bar_t);
but this fails with a
error: type/value mismatch at argument 1 in template parameter list for ‘template<template<class ...> class F> constexpr const boost::hana::template_t<F> boost::hana::template_<F>’
note: expected a template of type ‘template<class ...> class F’, got ‘template<template<class> class BarModel> class Foo’
The note suggests that hana::template_
does not work with template-of-templates.
Is this the case? If so, is there an alternative solution?