3

I have a template base class Base that implements a non-type template <int I> method called toto().

template<typename T>
class Base{ 
public:
  template<int I>
  void toto(){
  }
}; 

I also have a derived class, which calls toto() in a method use_toto() :

template<typename T>
class Derived : public Base<T> { 
public:
  void use_toto(){
    this->toto<1>();
  }
}; 

To call toto() I use the this pointor. Because I use template classes, this is a way to avoid the so-called two-stage (or dependent) name lookup issue. If I were calling directly toto<1>() I would get a non declared error.

The problem is that when I'm calling the method like this :

int main() 
{
  Derived<int> A;
  A.use_toto();
}

I have this kind of error :

error: invalid operands of types ‘<unresolved overloaded function type>‘ and ‘int’ to binary ‘operator<’

Actually, in this->toto<1>(); there is a confusion between the template symbol < and the less than operator.

Johann Bzh
  • 834
  • 3
  • 10
  • 25

0 Answers0