I.e. I got 2 specialized types of:
template <class Type, class Base> struct Instruction {};
to compile-time-select the appropriate type from within a type list.
like:
template <class Base> struct Instruction<Int2Type<Add_Type>, Base >
{
void add() {}
};
template <class Base> struct Instruction<Int2Type<Mul_Type>, Base > :
Instruction<Int2Type<Add_Type>, Base >
{
void mul()
{
add(); ???? <== not working (not resolved)
}
};
What’s the solution for this?
Thank you
Martin
add()doesn’t appear to depend on any template parameters (it’s not a “dependent name”), so the compiler doesn’t search for it in the templated base class.One way to make it clear to the compiler that
add()is supposed to be a member function/dependent name, is to explicitly specifythis->when you use the function:thisimplicitly depends on the template parameters, which makesadda dependent name that is looked up in the templated base class.See also this entry of the C++ FAQ lite, and the next/previous ones.