mercredi 1 février 2017

Libevent with C++11+ unique_ptr

I've recently tried to wrap libdbus types and libevent types with std::unique_ptr and custom deleter to simplify the code but I have a error with these libraries:

/opt/cross/armv7hl-meego-linux-gnueabi/include/c++/4.8.3/bits/unique_ptr.h:65:22: error: invalid application of 'sizeof' to incomplete type 'sockets::libev::event_base'
  static_assert(sizeof(_Tp)>0,
                      ^

The code is simple:

namespace sockets {
    // ... unix sockets stuff
    namespace libev {
        #include <event.h>
    } // libev
} // sockets

class A {
public:
    void run() {
        using namespace sockets;
        using namespace sockets::libev;
        using UniqueEventBase = std::unique_ptr<event_base>;
        // ...
    }   
};

So how do I write RAII-wrappers for event_base struct in this example ?

Aucun commentaire:

Enregistrer un commentaire