mardi 4 août 2015

Can't use vector of unique_ptr in Emscripten bindings

I am trying to bind some variables with Emscripten Bindings. And the problem is when I want to bind a vector of unique_ptr, emscripten try copy each entry and this obviously cause a compile error.

error: call to implicitly-deleted copy constructor of 'std::__1::unique_ptr ...

note: copy constructor is implicitly deleted because 'unique_ptr<...>' has a user-declared move constructor

But in the documentation of emscripten, they says that support unique_ptr.

Code:

class MyClass {
public:
    using Entities = std::vector<std::unique_ptr<Entity>>;
public:
    auto entities() const -> Entities const & { return _entities; }
private:
    Entities _entities;
};

EMSCRIPTEN_BINDINGS(MyClass) {
    emscripten::class_<MyClass>("MyClass")
        .property("entities", &MyClass::entities);
}

I can duplicate the vector with simple pointers but it's not a real solution. There is a special option/policy in emscripten to handle unique_ptr ?

Aucun commentaire:

Enregistrer un commentaire