MCPcopy Create free account
hub / github.com/pybind/pybind11 / tuple

Class tuple

include/pybind11/pytypes.h:2169–2189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2167};
2168
2169class tuple : public object {
2170public:
2171 PYBIND11_OBJECT_CVT(tuple, object, PyTuple_Check, PySequence_Tuple)
2172 template <typename SzType = ssize_t,
2173 detail::enable_if_t<std::is_integral<SzType>::value, int> = 0>
2174 // Some compilers generate link errors when using `const SzType &` here:
2175 explicit tuple(SzType size = 0) : object(PyTuple_New(ssize_t_cast(size)), stolen_t{}) {
2176 if (!m_ptr) {
2177 pybind11_fail("Could not allocate tuple object!");
2178 }
2179 }
2180 size_t size() const { return static_cast<size_t>(PyTuple_Size(m_ptr)); }
2181 bool empty() const { return size() == 0; }
2182 detail::tuple_accessor operator[](size_t index) const { return {*this, index}; }
2183 template <typename T, detail::enable_if_t<detail::is_pyobject<T>::value, int> = 0>
2184 detail::item_accessor operator[](T &&o) const {
2185 return object::operator[](std::forward<T>(o));
2186 }
2187 detail::tuple_iterator begin() const { return {*this, 0}; }
2188 detail::tuple_iterator end() const { return {*this, PyTuple_GET_SIZE(m_ptr)}; }
2189};
2190
2191// We need to put this into a separate function because the Intel compiler
2192// fails to compile enable_if_t<all_of<is_keyword_or_ds<Args>...>::value> part below

Callers 15

cxx_stdMethod · 0.85
_version.pyFile · 0.85
MySingletonClass · 0.85
TEST_SUBMODULEFunction · 0.85
test_tuple_rvalue_getterFunction · 0.85
test_vectorFunction · 0.85
test_dequeFunction · 0.85
test_arrayFunction · 0.85
test_valarrayFunction · 0.85

Calls

no outgoing calls

Tested by 12

TEST_SUBMODULEFunction · 0.68
test_tuple_rvalue_getterFunction · 0.68
test_vectorFunction · 0.68
test_dequeFunction · 0.68
test_arrayFunction · 0.68
test_valarrayFunction · 0.68
__init__Method · 0.68