24struct format_descriptor<
std::complex<T>, detail::enable_if_t<std::is_floating_point<T>::value>> {
26 static constexpr const char value[3] = {
'Z',
c,
'\0'};
27 static std::string
format() {
return std::string(value); }
35 detail::enable_if_t<std::is_floating_point<T>::value>>::value[3];
42struct is_fmt_numeric<
std::complex<T>, detail::enable_if_t<std::is_floating_point<T>::value>> {
43 static constexpr bool value =
true;
54 if (!convert && !PyComplex_Check(src.
ptr())) {
57 Py_complex result = PyComplex_AsCComplex(src.
ptr());
58 if (result.real == -1.0 && PyErr_Occurred()) {
62 value = std::complex<T>((T) result.real, (T) result.imag);
68 return PyComplex_FromDoubles((
double) src.real(), (
double) src.imag());
\rst Holds a reference to a Python object (no reference counting)
PyObject * ptr() const
Return the underlying PyObject * pointer.
bool load(handle src, bool convert)
PYBIND11_TYPE_CASTER(std::complex< T >, const_name("complex"))
static handle cast(const std::complex< T > &src, return_value_policy, handle)
#define PYBIND11_NAMESPACE_END(name)
#define PYBIND11_NAMESPACE_BEGIN(name)
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
constexpr descr< N - 1 > const_name(char const (&text)[N])
static constexpr bool value