jeudi 25 janvier 2018

std::function with templated Argument Types

struct Functor
{
public:
    template <typename... argtypes>
    Functor(std::function<void()> Function)
    {
        this->Function = Function;
    }

    ~Functor() {}

    void operator()() const
    {
        OutputDebugStringA("Hello there, General Kenobi");
        Function();
    }

private:
    std::function<void()> Function;
};

void gtk()
{
    OutputDebugStringA("What is happening to meeee");
}
Functor Draw = Functor(&gtk);
void foo() { Draw(); }

How can I make Functor's std::function accept Argument Types? I tried the following:

Functor(std::function<void(argtypes...)> Function)
Functor Draw = Functor<void>(&gtk);

But the compiler complains about 'typename not allowed'.

Aucun commentaire:

Enregistrer un commentaire