mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-29 08:32:02 +00:00
Create an empty python tuple in pybind::tuple default constructor.
Follow the same semantics as constructors of dict, list, and set by creating valid Python object in default constructor of a tuple class.
This commit is contained in:
parent
dd57a34e2d
commit
c83e062263
@ -372,8 +372,8 @@ public:
|
|||||||
|
|
||||||
class tuple : public object {
|
class tuple : public object {
|
||||||
public:
|
public:
|
||||||
PYBIND11_OBJECT_DEFAULT(tuple, object, PyTuple_Check)
|
PYBIND11_OBJECT(tuple, object, PyTuple_Check)
|
||||||
tuple(size_t size) : object(PyTuple_New((Py_ssize_t) size), false) { }
|
tuple(size_t size = 0) : object(PyTuple_New((Py_ssize_t) size), false) { }
|
||||||
size_t size() const { return (size_t) PyTuple_Size(m_ptr); }
|
size_t size() const { return (size_t) PyTuple_Size(m_ptr); }
|
||||||
detail::tuple_accessor operator[](size_t index) { return detail::tuple_accessor(ptr(), index); }
|
detail::tuple_accessor operator[](size_t index) { return detail::tuple_accessor(ptr(), index); }
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user