0

What do I need to fill in at xxxxx to make this program run?
except use using test_function = void(T::*)(Args...,...);, is there another way to make the program run.
I don't know if there is a type that can represent ....

template<typename T, typename ...Args>
using test_function = void(T::*)(Args...);

class myclass {
public:
    void test(const char* format, ...) {
        char buffer[MAX_PATH];
        va_list args;
        va_start(args, format);
        int size = _vsnprintf_s(buffer, MAX_PATH, MAX_PATH , format, args);
        va_end(args);
        std::cout << buffer << std::endl;
    }
};

int main()
{
    myclass mc;
    myclass* mcp;
    mcp = &mc;
    test_function<myclass, const char*, xxxxx> test_func = &myclass::test;
    (mcp->*test_func)("test:%d", 100);
}
273K
  • 29,503
  • 10
  • 41
  • 64
asa
  • 11
  • 3
    Does this answer your question? [Is it possible to pass va\_list to variadic template?](https://stackoverflow.com/questions/42317895/is-it-possible-to-pass-va-list-to-variadic-template) – dewaffled Jan 24 '22 at 00:56
  • @dewaffled it's helpful,thank you. – asa Jan 24 '22 at 02:44
  • [OT]: No need to use pointer (`mcp`), `.*` can be used instead of `->*`; (so `(mc.*test_func)("test:%d", 100);` – Jarod42 Jan 24 '22 at 10:38
  • @Jarod42 i know,i just want to use ->* – asa Jan 25 '22 at 11:03

0 Answers0