0

SSCCE of my problem is:

class Callee
{
public:
  int m1()
  {
    return 5;
  }

  constexpr static int (Callee::*method)() = &Callee::m1;
};

template <class O> int call(O &o, int (O::*m)())
{
  return (o.*m)();
}

int main()
{
  Callee callee;
  return
    (callee.*Callee::method)() // works fine
    *
    call<Callee>(callee, Callee::method) // causes undefined reference in GCC
  ;
}

This code compiled in clang (3.4-1) but failed in gcc (4.8.4) with message:

undefined reference to `Callee::method'

Shorter, I can call some class method by its pointer directly, but I can't call it from templated function. (It is more unclear, than I inherit from Callee, because both methods works fine) Why?

dyomas
  • 700
  • 5
  • 13

0 Answers0