I am having a problem that I was not able to re-produce with a small self-contained example. That is, I wrote such an example (appears below), but the small example compiles, while the actual code does not.
I have a function template defined in the base:
template<class ExplicitSpace>
struct ExplicitState {
...
template<class Neighbor>
std::vector<Neighbor> successors() const {...}
...
};
I have the following in the deriving type:
template <typename CostType_>
struct GridMapState: ExplicitState<GridMap<CostType_>> {
using Base = ExplicitState<GridMap<CostType_>>;
using Base::Base; // inherit constructors
using Base::successors; // this is supposed to do the trick
...
std::vector<Neighbor> successors() const {
// return static_cast<const Base *>(this)->template successors<Neighbor>();
// the above commented version compiles
return successors<Neighbor>(); // this does not compile
}
...
};
As the comment indicates, I can explicitly call successors()
of the base, but I cannot rely on using Base::successors;
to make it visible.
gcc 4.8.2. gives the following:
GridMapState.h: In member function ‘std::vector<StateNeighbor<GridMapState<typename ExplicitState<GridMap<CostType_> >::CostType> > > GridMapState<CostType_>::successors() const’:
GridMapState.h:20:35: error: expected primary-expression before ‘>’ token
return successors<Neighbor>();
Here is the small example that attempts to re-produce the problem, but it compiles just fine:
template <typename U>
struct A {
template <typename T>
T f() {return T(0);}
};
template <typename V>
struct B : A<int> {
using MyT = int;
using Base = A<int>;
using Base::f;
MyT f() {return f<MyT>();}
};
int main()
{
B<int> b;
std::cout << b.f() << std::endl;
return 0;
}