dimanche 19 janvier 2020

error: 'x' is not a type where x is constructor argument

class Example {
    //...
    static auto make = []() -> std::shared_ptr<receiveObject> {
        return std::make_shared<receiveObject>(Params::EchoBufferSize);
    };

    static auto recycle = [](std::shared_ptr<receiveObject> o) {
        //nothing for now
    };
    recycle::shared_pool<receiveObject> receivePool(make, recycler);
};

But I get

In file included from /home/project/AIPTCPClient.cpp:57:0:
/home/project/AIPTCPClient.h:312:57: error: 'make' is not a type
         recycle::shared_pool<receiveObject> receivePool(make, recycler);
                                                         ^~~~
/home/project/AIPTCPClient.h:312:63: error: 'recycler' is not a type
         recycle::shared_pool<receiveObject> receivePool(make, recycler);
                                                               ^~~~~~~~

As you can see in shared_pool, it requires two funcions, that's why I pass my lambdas. But C++ complain that they should be types. I don't get it. Why a constructor would need a type instead of an object?

Aucun commentaire:

Enregistrer un commentaire