I have class WtVector which contains an array[Dimension] and I don't want to access to its elements directly, so I came up with an idea to make mapper function type, so if I needed to have say 5th variable, I go like mapper(5) but not vector.el[4]
template <typename Space, int Dim>
struct WtVector {
Space el[Dim] = {};
typedef Space (*Mapper)(int);
Mapper getMapper();
};
But whenever I put WtVector<Space, Dim>::Mapper as type the compiler shouts that it's not a type
template <typename Space, int Dim>
struct WtVectorOps {
... some other stuff ...
static Space sqrMagnitue(WtVector<Space, Dim>::Mapper vec);
};
Error:
error: ‘WtVector<Space, Dim>::Mapper’ is not a type
static Space sqrMagnitue(WtVector<Space, Dim>::Mapper vec);
^
Is it possible to have such typedef in class and if not what is the best alternative solution? If there exists easier solution than creating subclass and defining operator()