mercredi 6 avril 2016

Callbacks with std::function

I am getting a compile error with a std::function callback. Here's the class declaration:

class Cloud
{
// ...
public:
    Cloud (std::string end_point) : end_point(end_point) {}
    void operator() (std::function<void(rapidjson::Document)> callback);
};

I store the callback in a private variable and then in a function of the class I'm trying to invoke the callback like this:

rapidjson::Document document;
this->callback(document);

This code gives me the error:

/Users/petilodie/Projects/TheGame/client/Classes/Cloud.cpp:67:20: Calling a private constructor of class 'rapidjson::GenericDocument<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>, rapidjson::CrtAllocator>'

I'm new to C++ and I'm sure I'm doing something wrong here. Any help is appreciated.

Aucun commentaire:

Enregistrer un commentaire