| 2112 | }; |
| 2113 | |
| 2114 | class tuple : public object { |
| 2115 | public: |
| 2116 | PYBIND11_OBJECT_CVT(tuple, object, PyTuple_Check, PySequence_Tuple) |
| 2117 | template <typename SzType = ssize_t, |
| 2118 | detail::enable_if_t<std::is_integral<SzType>::value, int> = 0> |
| 2119 | // Some compilers generate link errors when using `const SzType &` here: |
| 2120 | explicit tuple(SzType size = 0) : object(PyTuple_New(ssize_t_cast(size)), stolen_t{}) { |
| 2121 | if (!m_ptr) { |
| 2122 | pybind11_fail("Could not allocate tuple object!"); |
| 2123 | } |
| 2124 | } |
| 2125 | size_t size() const { return (size_t) PyTuple_Size(m_ptr); } |
| 2126 | bool empty() const { return size() == 0; } |
| 2127 | detail::tuple_accessor operator[](size_t index) const { return {*this, index}; } |
| 2128 | template <typename T, detail::enable_if_t<detail::is_pyobject<T>::value, int> = 0> |
| 2129 | detail::item_accessor operator[](T &&o) const { |
| 2130 | return object::operator[](std::forward<T>(o)); |
| 2131 | } |
| 2132 | detail::tuple_iterator begin() const { return {*this, 0}; } |
| 2133 | detail::tuple_iterator end() const { return {*this, PyTuple_GET_SIZE(m_ptr)}; } |
| 2134 | }; |
| 2135 | |
| 2136 | // We need to put this into a separate function because the Intel compiler |
| 2137 | // fails to compile enable_if_t<all_of<is_keyword_or_ds<Args>...>::value> part below |
no outgoing calls
no test coverage detected