@@ -85,13 +85,7 @@ class object_api : public pyobject_tag {
8585 or `object` subclass causes a call to ``__setitem__``.
8686 \endrst */
8787 item_accessor operator [](handle key) const ;
88- #define PYBIND11_PR3970
89- #ifdef PYBIND11_PR3970
90- # define PYBIND11_PR3970_ITEM_ACCESSOR
91- // / See above (the only difference is that the key's reference is stolen)
92- item_accessor operator [](object &&key) const ;
93- #endif
94- // / See above (the only difference is that the key is provided as a string literal)
88+ // / See above (the only difference is that they key is provided as a string literal)
9589 item_accessor operator [](const char *key) const ;
9690
9791 /* * \rst
@@ -101,12 +95,7 @@ class object_api : public pyobject_tag {
10195 or `object` subclass causes a call to ``setattr``.
10296 \endrst */
10397 obj_attr_accessor attr (handle key) const ;
104- // / See above (the only difference is that the key's reference is stolen)
105- #ifdef PYBIND11_PR3970
106- # define PYBIND11_PR3970_ATTR_ACCESSOR
107- obj_attr_accessor attr (object &&key) const ;
108- // / See above (the only difference is that the key is provided as a string literal)
109- #endif
98+ // / See above (the only difference is that they key is provided as a string literal)
11099 str_attr_accessor attr (const char *key) const ;
111100
112101 /* * \rst
@@ -695,12 +684,7 @@ class accessor : public object_api<accessor<Policy>> {
695684 }
696685 template <typename T>
697686 void operator =(T &&value) & {
698- #ifdef PYBIND11_PR3970
699- # define PYBIND11_PR3970_ENSURE_OBJECT
700- get_cache () = ensure_object (object_or_cast (std::forward<T>(value)));
701- #else
702687 get_cache () = reinterpret_borrow<object>(object_or_cast (std::forward<T>(value)));
703- #endif
704688 }
705689
706690 template <typename T = Policy>
@@ -728,11 +712,6 @@ class accessor : public object_api<accessor<Policy>> {
728712 }
729713
730714private:
731- #ifdef PYBIND11_PR3970_ENSURE_OBJECT
732- static object ensure_object (object &&o) { return std::move (o); }
733- static object ensure_object (handle h) { return reinterpret_borrow<object>(h); }
734- #endif
735-
736715 object &get_cache () const {
737716 if (!cache) {
738717 cache = Policy::get (obj, key);
@@ -1732,14 +1711,7 @@ class tuple : public object {
17321711 size_t size () const { return (size_t ) PyTuple_Size (m_ptr); }
17331712 bool empty () const { return size () == 0 ; }
17341713 detail::tuple_accessor operator [](size_t index) const { return {*this , index}; }
1735- #ifdef PYBIND11_PR3970
1736- template <typename T, detail::enable_if_t <detail::is_pyobject<T>::value, int > = 0 >
1737- detail::item_accessor operator [](T o) const {
1738- return object::operator [](std::forward<T>(o));
1739- }
1740- #else
17411714 detail::item_accessor operator [](handle h) const { return object::operator [](h); }
1742- #endif
17431715 detail::tuple_iterator begin () const { return {*this , 0 }; }
17441716 detail::tuple_iterator end () const { return {*this , PyTuple_GET_SIZE (m_ptr)}; }
17451717};
@@ -1799,14 +1771,7 @@ class sequence : public object {
17991771 }
18001772 bool empty () const { return size () == 0 ; }
18011773 detail::sequence_accessor operator [](size_t index) const { return {*this , index}; }
1802- #ifdef PYBIND11_PR3970
1803- template <typename T, detail::enable_if_t <detail::is_pyobject<T>::value, int > = 0 >
1804- detail::item_accessor operator [](T o) const {
1805- return object::operator [](std::forward<T>(o));
1806- }
1807- #else
18081774 detail::item_accessor operator [](handle h) const { return object::operator [](h); }
1809- #endif
18101775 detail::sequence_iterator begin () const { return {*this , 0 }; }
18111776 detail::sequence_iterator end () const { return {*this , PySequence_Size (m_ptr)}; }
18121777};
@@ -1825,14 +1790,7 @@ class list : public object {
18251790 size_t size () const { return (size_t ) PyList_Size (m_ptr); }
18261791 bool empty () const { return size () == 0 ; }
18271792 detail::list_accessor operator [](size_t index) const { return {*this , index}; }
1828- #ifdef PYBIND11_PR3970
1829- template <typename T, detail::enable_if_t <detail::is_pyobject<T>::value, int > = 0 >
1830- detail::item_accessor operator [](T o) const {
1831- return object::operator [](std::forward<T>(o));
1832- }
1833- #else
18341793 detail::item_accessor operator [](handle h) const { return object::operator [](h); }
1835- #endif
18361794 detail::list_iterator begin () const { return {*this , 0 }; }
18371795 detail::list_iterator end () const { return {*this , PyList_GET_SIZE (m_ptr)}; }
18381796 template <typename T>
@@ -2127,12 +2085,6 @@ template <typename D>
21272085iterator object_api<D>::end() const {
21282086 return iterator::sentinel ();
21292087}
2130- #ifdef PYBIND11_PR3970_ITEM_ACCESSOR
2131- template <typename D>
2132- item_accessor object_api<D>::operator [](object &&key) const {
2133- return {derived (), std::move (key)};
2134- }
2135- #endif
21362088template <typename D>
21372089item_accessor object_api<D>::operator [](handle key) const {
21382090 return {derived (), reinterpret_borrow<object>(key)};
@@ -2141,12 +2093,6 @@ template <typename D>
21412093item_accessor object_api<D>::operator [](const char *key) const {
21422094 return {derived (), pybind11::str (key)};
21432095}
2144- #ifdef PYBIND11_PR3970_ATTR_ACCESSOR
2145- template <typename D>
2146- obj_attr_accessor object_api<D>::attr(object &&key) const {
2147- return {derived (), std::move (key)};
2148- }
2149- #endif
21502096template <typename D>
21512097obj_attr_accessor object_api<D>::attr(handle key) const {
21522098 return {derived (), reinterpret_borrow<object>(key)};
0 commit comments