0

I have the following class:

class myClass
{
private:
    /* data */
public:
    myClass(/* args */);
    ~myClass();
    template<class T>
    static bool testFun1(const T &args);
    static bool testFun2(const int &args);

    void callerFun();

    template<class CallbackReturn = void, typename handlerReturn = bool, class ...Args>
    static handlerReturn errorHandler(myClass *obj, CallbackReturn (*callback)(const Args &...obj) = nullptr, const Args &...param);
};

I want to pass both "testFun1" and "testFun2" as arguments to "errorHandler" method.

I know how to pass "testFun2" :

myClass::errorHandler(this, &myClass::testFun2, 23);    

However, when I try something like the following, the program won't compile:

myClass::errorHandler(this, &myClass::testFun1<int, char, bool>, (int) 23, 'c', true);  

This is the compilation time error:

error: cannot convert ‘<unresolved overloaded function type>’ to ‘void (*)(const int&, const char&, const bool&)’
   48 |     myClass::errorHandler(this, &myClass::testFun1<int, char, bool>, (int) 23, 'c', true);

Thanks in advance

Juan_David
  • 126
  • 2
  • 11

0 Answers0