Skip to content

Code fails to compile when binding the std::deque of Non copy/move-constructible elements (similar to #487) #2190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ashhasthantra opened this issue Apr 28, 2020 · 1 comment

Comments

@ashhasthantra
Copy link

I see that there was an issue #487 which was supposedly fixed by #490. My code fails compilation with an error "use of deleted function" when binding the std::deque containing non copy/move-constructible elements.
Is there a fix for this issue? I couldn't find the changes which #490 claims. I am checked in master branch of pybind11 and I still get the same error.

@YannickJadoul
Copy link
Collaborator

@ashhasthantra What version of pybind11 are you on? What code did you try compiling?

I just tried this, and this works for me, so I can't reproduce your error:

#include <pybind11/pybind11.h>
#include <pybind11/stl_bind.h>

#include <deque>

namespace py = pybind11;

class X {
public:
        X(int i) : m_i(i) {}
        X(const X&) = delete;
        X(X&&) = default;
        ~X() = default;

        int get_i() { return m_i; }

private:
        int m_i;
};

PYBIND11_MODULE(example, m) {
        py::class_<X>(m, "X")
                .def(py::init<int>())
                .def("get_i", &X::get_i);
        py::bind_vector<std::vector<X>>(m, "VectorX");
        py::bind_vector<std::deque<X>>(m, "DequeX");
}

Please reopen if updating to pybind11 2.5.0 doesn't solve your problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants