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

Function as_unsigned

include/pybind11/pytypes.h:1914–1923  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1912// unsigned type: (A)-1 != (B)-1 when A and B are unsigned types of different sizes).
1913template <typename Unsigned>
1914Unsigned as_unsigned(PyObject *o) {
1915 if (sizeof(Unsigned) <= sizeof(unsigned long)) {
1916 unsigned long v = PyLong_AsUnsignedLong(o);
1917 return v == static_cast<unsigned long>(-1) && PyErr_Occurred() ? (Unsigned) -1
1918 : (Unsigned) v;
1919 }
1920 unsigned long long v = PyLong_AsUnsignedLongLong(o);
1921 return v == static_cast<unsigned long long>(-1) && PyErr_Occurred() ? (Unsigned) -1
1922 : (Unsigned) v;
1923}
1924PYBIND11_NAMESPACE_END(detail)
1925
1926class int_ : public object {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected