mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 08:03:55 +00:00
Compare commits
6 Commits
f4c20bbb2f
...
e227581b69
Author | SHA1 | Date | |
---|---|---|---|
|
e227581b69 | ||
|
95ed8a6c29 | ||
|
fdc20a8912 | ||
|
9ac9c07766 | ||
|
c3a313b0e4 | ||
|
3a74bc41ef |
@ -95,11 +95,8 @@ public:
|
|||||||
subclass causes a corresponding call to ``__getitem__``. Assigning a `handle`
|
subclass causes a corresponding call to ``__getitem__``. Assigning a `handle`
|
||||||
or `object` subclass causes a call to ``__setitem__``.
|
or `object` subclass causes a call to ``__setitem__``.
|
||||||
\endrst */
|
\endrst */
|
||||||
item_accessor operator[](handle key) const;
|
template <typename T>
|
||||||
/// See above (the only difference is that the key's reference is stolen)
|
item_accessor operator[](T &&key) const;
|
||||||
item_accessor operator[](object &&key) const;
|
|
||||||
/// See above (the only difference is that the key is provided as a string literal)
|
|
||||||
item_accessor operator[](const char *key) const;
|
|
||||||
|
|
||||||
/** \rst
|
/** \rst
|
||||||
Return an internal functor to access the object's attributes. Casting the
|
Return an internal functor to access the object's attributes. Casting the
|
||||||
@ -2493,16 +2490,9 @@ iterator object_api<D>::end() const {
|
|||||||
return iterator::sentinel();
|
return iterator::sentinel();
|
||||||
}
|
}
|
||||||
template <typename D>
|
template <typename D>
|
||||||
item_accessor object_api<D>::operator[](handle key) const {
|
template <typename T>
|
||||||
return {derived(), reinterpret_borrow<object>(key)};
|
item_accessor object_api<D>::operator[](T &&key) const {
|
||||||
}
|
return {derived(), detail::object_or_cast(std::forward<T>(key)).template cast<object>()};
|
||||||
template <typename D>
|
|
||||||
item_accessor object_api<D>::operator[](object &&key) const {
|
|
||||||
return {derived(), std::move(key)};
|
|
||||||
}
|
|
||||||
template <typename D>
|
|
||||||
item_accessor object_api<D>::operator[](const char *key) const {
|
|
||||||
return {derived(), pybind11::str(key)};
|
|
||||||
}
|
}
|
||||||
template <typename D>
|
template <typename D>
|
||||||
obj_attr_accessor object_api<D>::attr(handle key) const {
|
obj_attr_accessor object_api<D>::attr(handle key) const {
|
||||||
|
@ -234,6 +234,10 @@ TEST_SUBMODULE(pytypes, m) {
|
|||||||
m.def("tuple_ssize_t", []() { return py::tuple{(py::ssize_t) 0}; });
|
m.def("tuple_ssize_t", []() { return py::tuple{(py::ssize_t) 0}; });
|
||||||
m.def("tuple_size_t", []() { return py::tuple{(py::size_t) 0}; });
|
m.def("tuple_size_t", []() { return py::tuple{(py::size_t) 0}; });
|
||||||
m.def("get_tuple", []() { return py::make_tuple(42, py::none(), "spam"); });
|
m.def("get_tuple", []() { return py::make_tuple(42, py::none(), "spam"); });
|
||||||
|
m.def("access_tuple_with_int_index", []() {
|
||||||
|
py::object tpl = py::make_tuple(1, 2);
|
||||||
|
return tpl[1];
|
||||||
|
});
|
||||||
|
|
||||||
// test_simple_namespace
|
// test_simple_namespace
|
||||||
m.def("get_simple_namespace", []() {
|
m.def("get_simple_namespace", []() {
|
||||||
|
@ -208,6 +208,7 @@ def test_tuple():
|
|||||||
assert m.tuple_ssize_t() == ()
|
assert m.tuple_ssize_t() == ()
|
||||||
assert m.tuple_size_t() == ()
|
assert m.tuple_size_t() == ()
|
||||||
assert m.get_tuple() == (42, None, "spam")
|
assert m.get_tuple() == (42, None, "spam")
|
||||||
|
# assert m.access_tuple_with_int_index() == (2)
|
||||||
|
|
||||||
|
|
||||||
def test_simple_namespace():
|
def test_simple_namespace():
|
||||||
|
Loading…
Reference in New Issue
Block a user