aboutsummaryrefslogtreecommitdiff
path: root/include/pybind11/complex.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/pybind11/complex.h')
-rw-r--r--include/pybind11/complex.h31
1 files changed, 20 insertions, 11 deletions
diff --git a/include/pybind11/complex.h b/include/pybind11/complex.h
index f8327eb3..8a831c12 100644
--- a/include/pybind11/complex.h
+++ b/include/pybind11/complex.h
@@ -10,42 +10,50 @@
#pragma once
#include "pybind11.h"
+
#include <complex>
/// glibc defines I as a macro which breaks things, e.g., boost template names
#ifdef I
-# undef I
+# undef I
#endif
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
-template <typename T> struct format_descriptor<std::complex<T>, detail::enable_if_t<std::is_floating_point<T>::value>> {
+template <typename T>
+struct format_descriptor<std::complex<T>, detail::enable_if_t<std::is_floating_point<T>::value>> {
static constexpr const char c = format_descriptor<T>::c;
- static constexpr const char value[3] = { 'Z', c, '\0' };
+ static constexpr const char value[3] = {'Z', c, '\0'};
static std::string format() { return std::string(value); }
};
#ifndef PYBIND11_CPP17
-template <typename T> constexpr const char format_descriptor<
- std::complex<T>, detail::enable_if_t<std::is_floating_point<T>::value>>::value[3];
+template <typename T>
+constexpr const char
+ format_descriptor<std::complex<T>,
+ detail::enable_if_t<std::is_floating_point<T>::value>>::value[3];
#endif
PYBIND11_NAMESPACE_BEGIN(detail)
-template <typename T> struct is_fmt_numeric<std::complex<T>, detail::enable_if_t<std::is_floating_point<T>::value>> {
+template <typename T>
+struct is_fmt_numeric<std::complex<T>, detail::enable_if_t<std::is_floating_point<T>::value>> {
static constexpr bool value = true;
static constexpr int index = is_fmt_numeric<T>::index + 3;
};
-template <typename T> class type_caster<std::complex<T>> {
+template <typename T>
+class type_caster<std::complex<T>> {
public:
bool load(handle src, bool convert) {
- if (!src)
+ if (!src) {
return false;
- if (!convert && !PyComplex_Check(src.ptr()))
+ }
+ if (!convert && !PyComplex_Check(src.ptr())) {
return false;
+ }
Py_complex result = PyComplex_AsCComplex(src.ptr());
if (result.real == -1.0 && PyErr_Occurred()) {
PyErr_Clear();
@@ -55,11 +63,12 @@ public:
return true;
}
- static handle cast(const std::complex<T> &src, return_value_policy /* policy */, handle /* parent */) {
+ static handle
+ cast(const std::complex<T> &src, return_value_policy /* policy */, handle /* parent */) {
return PyComplex_FromDoubles((double) src.real(), (double) src.imag());
}
- PYBIND11_TYPE_CASTER(std::complex<T>, _("complex"));
+ PYBIND11_TYPE_CASTER(std::complex<T>, const_name("complex"));
};
PYBIND11_NAMESPACE_END(detail)
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)