I've the following problem. I have some classes that perform a mapping of an input array to an output array. I want to have the float type, as well as the lengths of the arrays as template parameters, so the mapping classes look like this:
template <typename FloatType, std::size_t input, std::size_t output>
class Mapper
{};
template <typename FloatType, std::size_t input, std::size_t output>
class FirstMapper : public Mapper<FloatType, input, output>
{};
template <typename FloatType, std::size_t input, std::size_t output>
class SecondMapper : public Mapper<FloatType, input, output>
{};
So far so good. My goal is to write a class that stacks different instances of these Mapper classes. I'd like to be able to write code like this:
StackedMapper<
double, // the FloatType, obviously
input_1, // the size of the first mapper's input array
FirstMapper, // the template template type of the first mapper
input_2, // the size of the first mapper's output and
// second mapper's input array
SecondMapper, // the template template type of the second mapper
input_3, // the size of the second mapper's output and
// third mapper's input array
FirstMapper, // the template template type of the third mapper
output // the size of the third mapper's output array
// ... any additional number of Mapper classes plus output sizes
> stacked_mapper;
Internally, the StackedMapper
class should store the mapper instances in a std::tuple
. I'd expect the tuple to have the following type:
std::tuple<
FirstMapper<double, input_1, input_2>,
SecondMapper<double, input_2, input_3>,
FirstMapper<double, input_3, output>
// ...
>;
As indicated with the ellipsis, I'd like to add an arbitrary number of Mapper classes. As you might have seen from the comments, the output size of one layer is equal to the input size of the next layer. The float type will be defined only once for all mappers in the stack.
Does anybody have an idea? I've seen this question, which solves the alternating types (integral constant and type) problem, however it doesn't seem to work with template template parameters, since I always get an error like expected a type, got 'FirstMapper'
.
Does anyone have an idea on this?