MCPcopy Create free account
hub / github.com/davisking/dlib / int_

Class int_

dlib/external/pybind11/include/pybind11/pytypes.h:1810–1843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1808PYBIND11_NAMESPACE_END(detail)
1809
1810class int_ : public object {
1811public:
1812 PYBIND11_OBJECT_CVT(int_, object, PYBIND11_LONG_CHECK, PyNumber_Long)
1813 int_() : object(PyLong_FromLong(0), stolen_t{}) {}
1814 // Allow implicit conversion from C++ integral types:
1815 template <typename T, detail::enable_if_t<std::is_integral<T>::value, int> = 0>
1816 // NOLINTNEXTLINE(google-explicit-constructor)
1817 int_(T value) {
1818 if (sizeof(T) <= sizeof(long)) {
1819 if (std::is_signed<T>::value) {
1820 m_ptr = PyLong_FromLong((long) value);
1821 } else {
1822 m_ptr = PyLong_FromUnsignedLong((unsigned long) value);
1823 }
1824 } else {
1825 if (std::is_signed<T>::value) {
1826 m_ptr = PyLong_FromLongLong((long long) value);
1827 } else {
1828 m_ptr = PyLong_FromUnsignedLongLong((unsigned long long) value);
1829 }
1830 }
1831 if (!m_ptr) {
1832 pybind11_fail("Could not allocate int object!");
1833 }
1834 }
1835
1836 template <typename T, detail::enable_if_t<std::is_integral<T>::value, int> = 0>
1837 // NOLINTNEXTLINE(google-explicit-constructor)
1838 operator T() const {
1839 return std::is_unsigned<T>::value ? detail::as_unsigned<T>(m_ptr)
1840 : sizeof(T) <= sizeof(long) ? (T) PyLong_AsLong(m_ptr)
1841 : (T) PYBIND11_LONG_AS_LONGLONG(m_ptr);
1842 }
1843};
1844
1845class float_ : public object {
1846public:

Callers 8

enum_nameFunction · 0.70
initFunction · 0.70
pybind11.hFile · 0.70
export_valuesFunction · 0.70
dtypeMethod · 0.70
sliceMethod · 0.70
index_to_objectMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected