mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-21 20:55:11 +00:00
clang-tidy readability-qualified-auto (#3702)
* Adding readability-qualified-auto to .clang-tidy
Ported from @henryiii's 287527f705
* fix: support Python < 3.6
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
parent
b4f5350d0d
commit
7769e7719c
@ -40,6 +40,7 @@ readability-implicit-bool-conversion,
|
||||
readability-make-member-function-const,
|
||||
readability-misplaced-array-index,
|
||||
readability-non-const-parameter,
|
||||
readability-qualified-auto,
|
||||
readability-redundant-function-ptr-dereference,
|
||||
readability-redundant-smartptr-get,
|
||||
readability-redundant-string-cstr,
|
||||
|
@ -311,7 +311,7 @@ struct type_record {
|
||||
bool is_final : 1;
|
||||
|
||||
PYBIND11_NOINLINE void add_base(const std::type_info &base, void *(*caster)(void *)) {
|
||||
auto base_info = detail::get_type_info(base, false);
|
||||
auto *base_info = detail::get_type_info(base, false);
|
||||
if (!base_info) {
|
||||
std::string tname(base.name());
|
||||
detail::clean_type_id(tname);
|
||||
|
@ -251,7 +251,7 @@ public:
|
||||
}
|
||||
|
||||
/* Check if this is a C++ type */
|
||||
auto &bases = all_type_info((PyTypeObject *) type::handle_of(h).ptr());
|
||||
const auto &bases = all_type_info((PyTypeObject *) type::handle_of(h).ptr());
|
||||
if (bases.size() == 1) { // Only allowing loading from a single-value type
|
||||
value = values_and_holders(reinterpret_cast<instance *>(h.ptr())).begin()->value_ptr();
|
||||
return true;
|
||||
@ -306,7 +306,7 @@ public:
|
||||
#else
|
||||
// Alternate approach for CPython: this does the same as the above, but optimized
|
||||
// using the CPython API so as to avoid an unneeded attribute lookup.
|
||||
else if (auto tp_as_number = src.ptr()->ob_type->tp_as_number) {
|
||||
else if (auto *tp_as_number = src.ptr()->ob_type->tp_as_number) {
|
||||
if (PYBIND11_NB_BOOL(tp_as_number)) {
|
||||
res = (*PYBIND11_NB_BOOL(tp_as_number))(src.ptr());
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ inline PyTypeObject *make_static_property_type() {
|
||||
issue no Python C API calls which could potentially invoke the
|
||||
garbage collector (the GC will call type_traverse(), which will in
|
||||
turn find the newly constructed type in an invalid state) */
|
||||
auto heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc(&PyType_Type, 0);
|
||||
auto *heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc(&PyType_Type, 0);
|
||||
if (!heap_type) {
|
||||
pybind11_fail("make_static_property_type(): error allocating type!");
|
||||
}
|
||||
@ -75,7 +75,7 @@ inline PyTypeObject *make_static_property_type() {
|
||||
heap_type->ht_qualname = name_obj.inc_ref().ptr();
|
||||
#endif
|
||||
|
||||
auto type = &heap_type->ht_type;
|
||||
auto *type = &heap_type->ht_type;
|
||||
type->tp_name = name;
|
||||
type->tp_base = type_incref(&PyProperty_Type);
|
||||
type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
|
||||
@ -130,7 +130,7 @@ extern "C" inline int pybind11_meta_setattro(PyObject* obj, PyObject* name, PyOb
|
||||
// 1. `Type.static_prop = value` --> descr_set: `Type.static_prop.__set__(value)`
|
||||
// 2. `Type.static_prop = other_static_prop` --> setattro: replace existing `static_prop`
|
||||
// 3. `Type.regular_attribute = value` --> setattro: regular attribute assignment
|
||||
const auto static_prop = (PyObject *) get_internals().static_property_type;
|
||||
auto *const static_prop = (PyObject *) get_internals().static_property_type;
|
||||
const auto call_descr_set = (descr != nullptr) && (value != nullptr)
|
||||
&& (PyObject_IsInstance(descr, static_prop) != 0)
|
||||
&& (PyObject_IsInstance(value, static_prop) == 0);
|
||||
@ -179,7 +179,7 @@ extern "C" inline PyObject *pybind11_meta_call(PyObject *type, PyObject *args, P
|
||||
}
|
||||
|
||||
// This must be a pybind11 instance
|
||||
auto instance = reinterpret_cast<detail::instance *>(self);
|
||||
auto *instance = reinterpret_cast<detail::instance *>(self);
|
||||
|
||||
// Ensure that the base __init__ function(s) were called
|
||||
for (const auto &vh : values_and_holders(instance)) {
|
||||
@ -245,7 +245,7 @@ inline PyTypeObject* make_default_metaclass() {
|
||||
issue no Python C API calls which could potentially invoke the
|
||||
garbage collector (the GC will call type_traverse(), which will in
|
||||
turn find the newly constructed type in an invalid state) */
|
||||
auto heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc(&PyType_Type, 0);
|
||||
auto *heap_type = (PyHeapTypeObject *) PyType_Type.tp_alloc(&PyType_Type, 0);
|
||||
if (!heap_type) {
|
||||
pybind11_fail("make_default_metaclass(): error allocating metaclass!");
|
||||
}
|
||||
@ -255,7 +255,7 @@ inline PyTypeObject* make_default_metaclass() {
|
||||
heap_type->ht_qualname = name_obj.inc_ref().ptr();
|
||||
#endif
|
||||
|
||||
auto type = &heap_type->ht_type;
|
||||
auto *type = &heap_type->ht_type;
|
||||
type->tp_name = name;
|
||||
type->tp_base = type_incref(&PyType_Type);
|
||||
type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;
|
||||
@ -285,7 +285,7 @@ inline PyTypeObject* make_default_metaclass() {
|
||||
inline void traverse_offset_bases(void *valueptr, const detail::type_info *tinfo, instance *self,
|
||||
bool (*f)(void * /*parentptr*/, instance * /*self*/)) {
|
||||
for (handle h : reinterpret_borrow<tuple>(tinfo->type->tp_bases)) {
|
||||
if (auto parent_tinfo = get_type_info((PyTypeObject *) h.ptr())) {
|
||||
if (auto *parent_tinfo = get_type_info((PyTypeObject *) h.ptr())) {
|
||||
for (auto &c : parent_tinfo->implicit_casts) {
|
||||
if (c.first == tinfo->cpptype) {
|
||||
auto *parentptr = c.second(valueptr);
|
||||
@ -344,7 +344,7 @@ inline PyObject *make_new_instance(PyTypeObject *type) {
|
||||
}
|
||||
#endif
|
||||
PyObject *self = type->tp_alloc(type, 0);
|
||||
auto inst = reinterpret_cast<instance *>(self);
|
||||
auto *inst = reinterpret_cast<instance *>(self);
|
||||
// Allocate the value/holder internals:
|
||||
inst->allocate_layout();
|
||||
|
||||
@ -369,14 +369,14 @@ extern "C" inline int pybind11_object_init(PyObject *self, PyObject *, PyObject
|
||||
|
||||
inline void add_patient(PyObject *nurse, PyObject *patient) {
|
||||
auto &internals = get_internals();
|
||||
auto instance = reinterpret_cast<detail::instance *>(nurse);
|
||||
auto *instance = reinterpret_cast<detail::instance *>(nurse);
|
||||
instance->has_patients = true;
|
||||
Py_INCREF(patient);
|
||||
internals.patients[nurse].push_back(patient);
|
||||
}
|
||||
|
||||
inline void clear_patients(PyObject *self) {
|
||||
auto instance = reinterpret_cast<detail::instance *>(self);
|
||||
auto *instance = reinterpret_cast<detail::instance *>(self);
|
||||
auto &internals = get_internals();
|
||||
auto pos = internals.patients.find(self);
|
||||
assert(pos != internals.patients.end());
|
||||
@ -394,7 +394,7 @@ inline void clear_patients(PyObject *self) {
|
||||
/// Clears all internal data from the instance and removes it from registered instances in
|
||||
/// preparation for deallocation.
|
||||
inline void clear_instance(PyObject *self) {
|
||||
auto instance = reinterpret_cast<detail::instance *>(self);
|
||||
auto *instance = reinterpret_cast<detail::instance *>(self);
|
||||
|
||||
// Deallocate any values/holders, if present:
|
||||
for (auto &v_h : values_and_holders(instance)) {
|
||||
@ -435,7 +435,7 @@ inline void clear_instance(PyObject *self) {
|
||||
extern "C" inline void pybind11_object_dealloc(PyObject *self) {
|
||||
clear_instance(self);
|
||||
|
||||
auto type = Py_TYPE(self);
|
||||
auto *type = Py_TYPE(self);
|
||||
type->tp_free(self);
|
||||
|
||||
#if PY_VERSION_HEX < 0x03080000
|
||||
@ -464,7 +464,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
|
||||
issue no Python C API calls which could potentially invoke the
|
||||
garbage collector (the GC will call type_traverse(), which will in
|
||||
turn find the newly constructed type in an invalid state) */
|
||||
auto heap_type = (PyHeapTypeObject *) metaclass->tp_alloc(metaclass, 0);
|
||||
auto *heap_type = (PyHeapTypeObject *) metaclass->tp_alloc(metaclass, 0);
|
||||
if (!heap_type) {
|
||||
pybind11_fail("make_object_base_type(): error allocating type!");
|
||||
}
|
||||
@ -474,7 +474,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
|
||||
heap_type->ht_qualname = name_obj.inc_ref().ptr();
|
||||
#endif
|
||||
|
||||
auto type = &heap_type->ht_type;
|
||||
auto *type = &heap_type->ht_type;
|
||||
type->tp_name = name;
|
||||
type->tp_base = type_incref(&PyBaseObject_Type);
|
||||
type->tp_basicsize = static_cast<ssize_t>(sizeof(instance));
|
||||
@ -538,7 +538,7 @@ extern "C" inline int pybind11_clear(PyObject *self) {
|
||||
|
||||
/// Give instances of this type a `__dict__` and opt into garbage collection.
|
||||
inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) {
|
||||
auto type = &heap_type->ht_type;
|
||||
auto *type = &heap_type->ht_type;
|
||||
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
|
||||
type->tp_dictoffset = type->tp_basicsize; // place dict at the end
|
||||
type->tp_basicsize += (ssize_t)sizeof(PyObject *); // and allocate enough space for it
|
||||
@ -639,11 +639,11 @@ inline PyObject* make_new_python_type(const type_record &rec) {
|
||||
}
|
||||
}
|
||||
|
||||
auto full_name = c_str(
|
||||
const auto *full_name = c_str(
|
||||
#if !defined(PYPY_VERSION)
|
||||
module_ ? str(module_).cast<std::string>() + "." + rec.name :
|
||||
#endif
|
||||
rec.name);
|
||||
rec.name);
|
||||
|
||||
char *tp_doc = nullptr;
|
||||
if (rec.doc && options::show_user_defined_docstrings()) {
|
||||
@ -656,17 +656,16 @@ inline PyObject* make_new_python_type(const type_record &rec) {
|
||||
|
||||
auto &internals = get_internals();
|
||||
auto bases = tuple(rec.bases);
|
||||
auto base = (bases.empty()) ? internals.instance_base
|
||||
: bases[0].ptr();
|
||||
auto *base = (bases.empty()) ? internals.instance_base : bases[0].ptr();
|
||||
|
||||
/* Danger zone: from now (and until PyType_Ready), make sure to
|
||||
issue no Python C API calls which could potentially invoke the
|
||||
garbage collector (the GC will call type_traverse(), which will in
|
||||
turn find the newly constructed type in an invalid state) */
|
||||
auto metaclass = rec.metaclass.ptr() ? (PyTypeObject *) rec.metaclass.ptr()
|
||||
: internals.default_metaclass;
|
||||
auto *metaclass
|
||||
= rec.metaclass.ptr() ? (PyTypeObject *) rec.metaclass.ptr() : internals.default_metaclass;
|
||||
|
||||
auto heap_type = (PyHeapTypeObject *) metaclass->tp_alloc(metaclass, 0);
|
||||
auto *heap_type = (PyHeapTypeObject *) metaclass->tp_alloc(metaclass, 0);
|
||||
if (!heap_type) {
|
||||
pybind11_fail(std::string(rec.name) + ": Unable to create type object!");
|
||||
}
|
||||
@ -676,7 +675,7 @@ inline PyObject* make_new_python_type(const type_record &rec) {
|
||||
heap_type->ht_qualname = qualname.inc_ref().ptr();
|
||||
#endif
|
||||
|
||||
auto type = &heap_type->ht_type;
|
||||
auto *type = &heap_type->ht_type;
|
||||
type->tp_name = full_name;
|
||||
type->tp_doc = tp_doc;
|
||||
type->tp_base = type_incref((PyTypeObject *)base);
|
||||
|
@ -301,7 +301,7 @@ bool handle_nested_exception(const T &exc, const std::exception_ptr &p) {
|
||||
template <class T,
|
||||
enable_if_t<!std::is_same<std::nested_exception, remove_cvref_t<T>>::value, int> = 0>
|
||||
bool handle_nested_exception(const T &exc, const std::exception_ptr &p) {
|
||||
if (auto *nep = dynamic_cast<const std::nested_exception *>(std::addressof(exc))) {
|
||||
if (const auto *nep = dynamic_cast<const std::nested_exception *>(std::addressof(exc))) {
|
||||
return handle_nested_exception(*nep, p);
|
||||
}
|
||||
return false;
|
||||
@ -338,7 +338,7 @@ inline void translate_exception(std::exception_ptr p) {
|
||||
return;
|
||||
} catch (const builtin_exception &e) {
|
||||
// Could not use template since it's an abstract class.
|
||||
if (auto *nep = dynamic_cast<const std::nested_exception *>(std::addressof(e))) {
|
||||
if (const auto *nep = dynamic_cast<const std::nested_exception *>(std::addressof(e))) {
|
||||
handle_nested_exception(*nep, p);
|
||||
}
|
||||
e.set_error();
|
||||
|
@ -109,7 +109,7 @@ PYBIND11_NOINLINE void all_type_info_populate(PyTypeObject *t, std::vector<type_
|
||||
|
||||
auto const &type_dict = get_internals().registered_types_py;
|
||||
for (size_t i = 0; i < check.size(); i++) {
|
||||
auto type = check[i];
|
||||
auto *type = check[i];
|
||||
// Ignore Python2 old-style class super type:
|
||||
if (!PyType_Check((PyObject *) type)) {
|
||||
continue;
|
||||
@ -178,7 +178,7 @@ inline const std::vector<detail::type_info *> &all_type_info(PyTypeObject *type)
|
||||
* `all_type_info` instead if you want to support multiple bases.
|
||||
*/
|
||||
PYBIND11_NOINLINE detail::type_info* get_type_info(PyTypeObject *type) {
|
||||
auto &bases = all_type_info(type);
|
||||
const auto &bases = all_type_info(type);
|
||||
if (bases.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -210,10 +210,10 @@ inline detail::type_info *get_global_type_info(const std::type_index &tp) {
|
||||
/// Return the type info for a given C++ type; on lookup failure can either throw or return nullptr.
|
||||
PYBIND11_NOINLINE detail::type_info *get_type_info(const std::type_index &tp,
|
||||
bool throw_if_missing = false) {
|
||||
if (auto ltype = get_local_type_info(tp)) {
|
||||
if (auto *ltype = get_local_type_info(tp)) {
|
||||
return ltype;
|
||||
}
|
||||
if (auto gtype = get_global_type_info(tp)) {
|
||||
if (auto *gtype = get_global_type_info(tp)) {
|
||||
return gtype;
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ PYBIND11_NOINLINE handle find_registered_python_instance(void *src,
|
||||
const detail::type_info *tinfo) {
|
||||
auto it_instances = get_internals().registered_instances.equal_range(src);
|
||||
for (auto it_i = it_instances.first; it_i != it_instances.second; ++it_i) {
|
||||
for (auto instance_type : detail::all_type_info(Py_TYPE(it_i->second))) {
|
||||
for (auto *instance_type : detail::all_type_info(Py_TYPE(it_i->second))) {
|
||||
if (instance_type && same_type(*instance_type->cpptype, *tinfo->cpptype)) {
|
||||
return handle((PyObject *) it_i->second).inc_ref();
|
||||
}
|
||||
@ -397,7 +397,7 @@ PYBIND11_NOINLINE value_and_holder instance::get_value_and_holder(const type_inf
|
||||
}
|
||||
|
||||
PYBIND11_NOINLINE void instance::allocate_layout() {
|
||||
auto &tinfo = all_type_info(Py_TYPE(this));
|
||||
const auto &tinfo = all_type_info(Py_TYPE(this));
|
||||
|
||||
const size_t n_types = tinfo.size();
|
||||
|
||||
@ -421,7 +421,7 @@ PYBIND11_NOINLINE void instance::allocate_layout() {
|
||||
// values that tracks whether each associated holder has been initialized. Each [block] is
|
||||
// padded, if necessary, to an integer multiple of sizeof(void *).
|
||||
size_t space = 0;
|
||||
for (auto t : tinfo) {
|
||||
for (auto *t : tinfo) {
|
||||
space += 1; // value pointer
|
||||
space += t->holder_size_in_ptrs; // holder instance
|
||||
}
|
||||
@ -582,7 +582,7 @@ public:
|
||||
}
|
||||
|
||||
auto inst = reinterpret_steal<object>(make_new_instance(tinfo->type));
|
||||
auto wrapper = reinterpret_cast<instance *>(inst.ptr());
|
||||
auto *wrapper = reinterpret_cast<instance *>(inst.ptr());
|
||||
wrapper->owned = false;
|
||||
void *&valueptr = values_and_holders(wrapper).begin()->value_ptr();
|
||||
|
||||
@ -656,7 +656,7 @@ public:
|
||||
auto *&vptr = v_h.value_ptr();
|
||||
// Lazy allocation for unallocated values:
|
||||
if (vptr == nullptr) {
|
||||
auto *type = v_h.type ? v_h.type : typeinfo;
|
||||
const auto *type = v_h.type ? v_h.type : typeinfo;
|
||||
if (type->operator_new) {
|
||||
vptr = type->operator_new(type->type_size);
|
||||
} else {
|
||||
@ -675,7 +675,7 @@ public:
|
||||
value = vptr;
|
||||
}
|
||||
bool try_implicit_casts(handle src, bool convert) {
|
||||
for (auto &cast : typeinfo->implicit_casts) {
|
||||
for (const auto &cast : typeinfo->implicit_casts) {
|
||||
type_caster_generic sub_caster(*cast.first);
|
||||
if (sub_caster.load(src, convert)) {
|
||||
value = cast.second(sub_caster.value);
|
||||
@ -718,7 +718,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto result = foreign_typeinfo->module_local_load(src.ptr(), foreign_typeinfo)) {
|
||||
if (auto *result = foreign_typeinfo->module_local_load(src.ptr(), foreign_typeinfo)) {
|
||||
value = result;
|
||||
return true;
|
||||
}
|
||||
@ -750,7 +750,7 @@ public:
|
||||
}
|
||||
// Case 2: We have a derived class
|
||||
if (PyType_IsSubtype(srctype, typeinfo->type)) {
|
||||
auto &bases = all_type_info(srctype);
|
||||
const auto &bases = all_type_info(srctype);
|
||||
bool no_cpp_mi = typeinfo->simple_type;
|
||||
|
||||
// Case 2a: the python type is a Python-inherited derived class that inherits from just
|
||||
@ -767,7 +767,7 @@ public:
|
||||
// we can find an exact match (or, for a simple C++ type, an inherited match); if so, we
|
||||
// can safely reinterpret_cast to the relevant pointer.
|
||||
if (bases.size() > 1) {
|
||||
for (auto base : bases) {
|
||||
for (auto *base : bases) {
|
||||
if (no_cpp_mi ? PyType_IsSubtype(base->type, typeinfo->type) : base->type == typeinfo->type) {
|
||||
this_.load_value(reinterpret_cast<instance *>(src.ptr())->get_value_and_holder(base));
|
||||
return true;
|
||||
@ -785,7 +785,7 @@ public:
|
||||
|
||||
// Perform an implicit conversion
|
||||
if (convert) {
|
||||
for (auto &converter : typeinfo->implicit_conversions) {
|
||||
for (const auto &converter : typeinfo->implicit_conversions) {
|
||||
auto temp = reinterpret_steal<object>(converter(src.ptr(), typeinfo->type));
|
||||
if (load_impl<ThisT>(temp, false)) {
|
||||
loader_life_support::add_patient(temp);
|
||||
@ -799,7 +799,7 @@ public:
|
||||
|
||||
// Failed to match local typeinfo. Try again with global.
|
||||
if (typeinfo->module_local) {
|
||||
if (auto gtype = get_global_type_info(*typeinfo->cpptype)) {
|
||||
if (auto *gtype = get_global_type_info(*typeinfo->cpptype)) {
|
||||
typeinfo = gtype;
|
||||
return load(src, false);
|
||||
}
|
||||
@ -970,7 +970,7 @@ public:
|
||||
// polymorphic type (using RTTI by default, but can be overridden by specializing
|
||||
// polymorphic_type_hook). If the instance isn't derived, returns the base version.
|
||||
static std::pair<const void *, const type_info *> src_and_type(const itype *src) {
|
||||
auto &cast_type = typeid(itype);
|
||||
const auto &cast_type = typeid(itype);
|
||||
const std::type_info *instance_type = nullptr;
|
||||
const void *vsrc = polymorphic_type_hook<itype>::get(src, instance_type);
|
||||
if (instance_type && !same_type(cast_type, *instance_type)) {
|
||||
|
@ -157,7 +157,7 @@ inline void set_interpreter_argv(int argc, const char *const *argv, bool add_pro
|
||||
widened_argv[ii] = widened_argv_entries.back().get();
|
||||
}
|
||||
|
||||
auto pysys_argv = widened_argv.get();
|
||||
auto *pysys_argv = widened_argv.get();
|
||||
#else
|
||||
// python 2.x
|
||||
std::vector<std::string> strings{safe_argv, safe_argv + argv_size};
|
||||
|
@ -46,10 +46,10 @@ public:
|
||||
captured variables), in which case the roundtrip can be avoided.
|
||||
*/
|
||||
if (auto cfunc = func.cpp_function()) {
|
||||
auto cfunc_self = PyCFunction_GET_SELF(cfunc.ptr());
|
||||
auto *cfunc_self = PyCFunction_GET_SELF(cfunc.ptr());
|
||||
if (isinstance<capsule>(cfunc_self)) {
|
||||
auto c = reinterpret_borrow<capsule>(cfunc_self);
|
||||
auto rec = (function_record *) c;
|
||||
auto *rec = (function_record *) c;
|
||||
|
||||
while (rec != nullptr) {
|
||||
if (rec->is_stateless
|
||||
|
@ -137,6 +137,8 @@ public:
|
||||
auto &internals = detail::get_internals();
|
||||
tstate = PyEval_SaveThread();
|
||||
if (disassoc) {
|
||||
// Python >= 3.7 can remove this, it's an int before 3.7
|
||||
// NOLINTNEXTLINE(readability-qualified-auto)
|
||||
auto key = internals.tstate;
|
||||
PYBIND11_TLS_DELETE_VALUE(key);
|
||||
}
|
||||
@ -160,6 +162,8 @@ public:
|
||||
PyEval_RestoreThread(tstate);
|
||||
}
|
||||
if (disassoc) {
|
||||
// Python >= 3.7 can remove this, it's an int before 3.7
|
||||
// NOLINTNEXTLINE(readability-qualified-auto)
|
||||
auto key = detail::get_internals().tstate;
|
||||
PYBIND11_TLS_REPLACE_VALUE(key, tstate);
|
||||
}
|
||||
|
@ -1130,7 +1130,7 @@ public:
|
||||
static constexpr int value = values[detail::is_fmt_numeric<T>::index];
|
||||
|
||||
static pybind11::dtype dtype() {
|
||||
if (auto ptr = npy_api::get().PyArray_DescrFromType_(value)) {
|
||||
if (auto *ptr = npy_api::get().PyArray_DescrFromType_(value)) {
|
||||
return reinterpret_steal<pybind11::dtype>(ptr);
|
||||
}
|
||||
pybind11_fail("Unsupported buffer format!");
|
||||
@ -1200,7 +1200,7 @@ PYBIND11_NOINLINE void register_structured_dtype(
|
||||
formats.append(field.descr);
|
||||
offsets.append(pybind11::int_(field.offset));
|
||||
}
|
||||
auto dtype_ptr
|
||||
auto *dtype_ptr
|
||||
= pybind11::dtype(std::move(names), std::move(formats), std::move(offsets), itemsize)
|
||||
.release()
|
||||
.ptr();
|
||||
@ -1699,7 +1699,7 @@ private:
|
||||
}
|
||||
|
||||
/* Call the function */
|
||||
auto mutable_data = returned_array::mutable_data(result);
|
||||
auto *mutable_data = returned_array::mutable_data(result);
|
||||
if (trivial == broadcast_trivial::non_trivial) {
|
||||
apply_broadcast(buffers, params, mutable_data, size, shape, i_seq, vi_seq, bi_seq);
|
||||
} else {
|
||||
|
@ -162,7 +162,7 @@ protected:
|
||||
/* Store the function including any extra state it might have (e.g. a lambda capture object) */
|
||||
// The unique_ptr makes sure nothing is leaked in case of an exception.
|
||||
auto unique_rec = make_function_record();
|
||||
auto rec = unique_rec.get();
|
||||
auto *rec = unique_rec.get();
|
||||
|
||||
/* Store the capture object directly in the function record if there is enough space */
|
||||
if (PYBIND11_SILENCE_MSVC_C4127(sizeof(capture) <= sizeof(rec->data))) {
|
||||
@ -220,8 +220,8 @@ protected:
|
||||
process_attributes<Extra...>::precall(call);
|
||||
|
||||
/* Get a pointer to the capture object */
|
||||
auto data = (sizeof(capture) <= sizeof(call.func.data)
|
||||
? &call.func.data : call.func.data[0]);
|
||||
const auto *data = (sizeof(capture) <= sizeof(call.func.data) ? &call.func.data
|
||||
: call.func.data[0]);
|
||||
auto *cap = const_cast<capture *>(reinterpret_cast<const capture *>(data));
|
||||
|
||||
/* Override policy for rvalues -- usually to enforce rvp::move on an rvalue */
|
||||
@ -287,12 +287,12 @@ protected:
|
||||
class strdup_guard {
|
||||
public:
|
||||
~strdup_guard() {
|
||||
for (auto s : strings) {
|
||||
for (auto *s : strings) {
|
||||
std::free(s);
|
||||
}
|
||||
}
|
||||
char *operator()(const char *s) {
|
||||
auto t = PYBIND11_COMPAT_STRDUP(s);
|
||||
auto *t = PYBIND11_COMPAT_STRDUP(s);
|
||||
strings.push_back(t);
|
||||
return t;
|
||||
}
|
||||
@ -309,7 +309,7 @@ protected:
|
||||
// Do NOT receive `unique_rec` by value. If this function fails to move out the unique_ptr,
|
||||
// we do not want this to destuct the pointer. `initialize` (the caller) still relies on the
|
||||
// pointee being alive after this call. Only move out if a `capsule` is going to keep it alive.
|
||||
auto rec = unique_rec.get();
|
||||
auto *rec = unique_rec.get();
|
||||
|
||||
// Keep track of strdup'ed strings, and clean them up as long as the function's capsule
|
||||
// has not taken ownership yet (when `unique_rec.release()` is called).
|
||||
@ -355,7 +355,7 @@ protected:
|
||||
std::string signature;
|
||||
size_t type_index = 0, arg_index = 0;
|
||||
bool is_starred = false;
|
||||
for (auto *pc = text; *pc != '\0'; ++pc) {
|
||||
for (const auto *pc = text; *pc != '\0'; ++pc) {
|
||||
const auto c = *pc;
|
||||
|
||||
if (c == '{') {
|
||||
@ -396,7 +396,7 @@ protected:
|
||||
if (!t) {
|
||||
pybind11_fail("Internal error while parsing type signature (1)");
|
||||
}
|
||||
if (auto tinfo = detail::get_type_info(*t)) {
|
||||
if (auto *tinfo = detail::get_type_info(*t)) {
|
||||
handle th((PyObject *) tinfo->type);
|
||||
signature +=
|
||||
th.attr("__module__").cast<std::string>() + "." +
|
||||
@ -535,7 +535,7 @@ protected:
|
||||
}
|
||||
// Then specific overload signatures
|
||||
bool first_user_def = true;
|
||||
for (auto it = chain_start; it != nullptr; it = it->next) {
|
||||
for (auto *it = chain_start; it != nullptr; it = it->next) {
|
||||
if (options::show_function_signatures()) {
|
||||
if (index > 0) {
|
||||
signatures += "\n";
|
||||
@ -652,8 +652,8 @@ protected:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto tinfo = get_type_info((PyTypeObject *) overloads->scope.ptr());
|
||||
const auto pi = reinterpret_cast<instance *>(parent.ptr());
|
||||
auto *const tinfo = get_type_info((PyTypeObject *) overloads->scope.ptr());
|
||||
auto *const pi = reinterpret_cast<instance *>(parent.ptr());
|
||||
self_value_and_holder = pi->get_value_and_holder(tinfo, true);
|
||||
|
||||
// If this value is already registered it must mean __init__ is invoked multiple times;
|
||||
@ -1207,7 +1207,7 @@ public:
|
||||
/* m_clear */ nullptr,
|
||||
/* m_free */ nullptr
|
||||
};
|
||||
auto m = PyModule_Create(def);
|
||||
auto *m = PyModule_Create(def);
|
||||
#else
|
||||
// Ignore module_def *def; only necessary for Python 3
|
||||
(void) def;
|
||||
@ -1317,7 +1317,7 @@ protected:
|
||||
void mark_parents_nonsimple(PyTypeObject *value) {
|
||||
auto t = reinterpret_borrow<tuple>(value->tp_bases);
|
||||
for (handle h : t) {
|
||||
auto tinfo2 = get_type_info((PyTypeObject *) h.ptr());
|
||||
auto *tinfo2 = get_type_info((PyTypeObject *) h.ptr());
|
||||
if (tinfo2) {
|
||||
tinfo2->simple_type = false;
|
||||
}
|
||||
@ -1329,7 +1329,7 @@ protected:
|
||||
buffer_info *(*get_buffer)(PyObject *, void *),
|
||||
void *get_buffer_data) {
|
||||
auto *type = (PyHeapTypeObject*) m_ptr;
|
||||
auto tinfo = detail::get_type_info(&type->ht_type);
|
||||
auto *tinfo = detail::get_type_info(&type->ht_type);
|
||||
|
||||
if (!type->ht_type.tp_as_buffer) {
|
||||
pybind11_fail("To be able to register buffer protocol support for the type '"
|
||||
@ -2304,7 +2304,7 @@ template <typename InputType, typename OutputType> void implicitly_convertible()
|
||||
return result;
|
||||
};
|
||||
|
||||
if (auto tinfo = detail::get_type_info(typeid(OutputType))) {
|
||||
if (auto *tinfo = detail::get_type_info(typeid(OutputType))) {
|
||||
tinfo->implicit_conversions.push_back(implicit_caster);
|
||||
} else {
|
||||
pybind11_fail("implicitly_convertible: Unable to find type " + type_id<OutputType>());
|
||||
@ -2568,7 +2568,7 @@ PYBIND11_NAMESPACE_END(detail)
|
||||
:return: The Python method by this name from the object or an empty function wrapper.
|
||||
\endrst */
|
||||
template <class T> function get_override(const T *this_ptr, const char *name) {
|
||||
auto tinfo = detail::get_type_info(typeid(T));
|
||||
auto *tinfo = detail::get_type_info(typeid(T));
|
||||
return tinfo ? detail::get_type_override(this_ptr, tinfo, name) : function();
|
||||
}
|
||||
|
||||
|
@ -1524,7 +1524,7 @@ public:
|
||||
/// Get the pointer the capsule holds.
|
||||
template<typename T = void>
|
||||
T* get_pointer() const {
|
||||
auto name = this->name();
|
||||
const auto *name = this->name();
|
||||
T *result = static_cast<T *>(PyCapsule_GetPointer(m_ptr, name));
|
||||
if (!result) {
|
||||
PyErr_Clear();
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
PyObject* native = nullptr;
|
||||
if constexpr (std::is_same_v<typename T::value_type, char>) {
|
||||
if (PyUnicode_FSConverter(buf, &native) != 0) {
|
||||
if (auto c_str = PyBytes_AsString(native)) {
|
||||
if (auto *c_str = PyBytes_AsString(native)) {
|
||||
// AsString returns a pointer to the internal buffer, which
|
||||
// must not be free'd.
|
||||
value = c_str;
|
||||
@ -76,7 +76,7 @@ public:
|
||||
}
|
||||
} else if constexpr (std::is_same_v<typename T::value_type, wchar_t>) {
|
||||
if (PyUnicode_FSDecoder(buf, &native) != 0) {
|
||||
if (auto c_str = PyUnicode_AsWideCharString(native, nullptr)) {
|
||||
if (auto *c_str = PyUnicode_AsWideCharString(native, nullptr)) {
|
||||
// AsWideCharString returns a new string that must be free'd.
|
||||
value = c_str; // Copies the string.
|
||||
PyMem_Free(c_str);
|
||||
|
@ -464,7 +464,7 @@ class_<Vector, holder_type> bind_vector(handle scope, std::string const &name, A
|
||||
// If the value_type is unregistered (e.g. a converting type) or is itself registered
|
||||
// module-local then make the vector binding module-local as well:
|
||||
using vtype = typename Vector::value_type;
|
||||
auto vtype_info = detail::get_type_info(typeid(vtype));
|
||||
auto *vtype_info = detail::get_type_info(typeid(vtype));
|
||||
bool local = !vtype_info || vtype_info->module_local;
|
||||
|
||||
Class_ cl(scope, name.c_str(), pybind11::module_local(local), std::forward<Args>(args)...);
|
||||
@ -651,7 +651,7 @@ class_<Map, holder_type> bind_map(handle scope, const std::string &name, Args&&.
|
||||
// If either type is a non-module-local bound type then make the map binding non-local as well;
|
||||
// otherwise (e.g. both types are either module-local or converting) the map will be
|
||||
// module-local.
|
||||
auto tinfo = detail::get_type_info(typeid(MappedType));
|
||||
auto *tinfo = detail::get_type_info(typeid(MappedType));
|
||||
bool local = !tinfo || tinfo->module_local;
|
||||
if (local) {
|
||||
tinfo = detail::get_type_info(typeid(KeyType));
|
||||
|
@ -89,7 +89,7 @@ TEST_SUBMODULE(buffers, m) {
|
||||
throw std::runtime_error("Incompatible buffer format!");
|
||||
}
|
||||
|
||||
auto v = new Matrix(info.shape[0], info.shape[1]);
|
||||
auto *v = new Matrix(info.shape[0], info.shape[1]);
|
||||
memcpy(v->data(), info.ptr, sizeof(float) * (size_t) (v->rows() * v->cols()));
|
||||
return v;
|
||||
}))
|
||||
|
@ -277,7 +277,7 @@ TEST_SUBMODULE(builtin_casters, m) {
|
||||
m.def("refwrap_list", [](bool copy) {
|
||||
static IncType x1(1), x2(2);
|
||||
py::list l;
|
||||
for (auto &f : {std::ref(x1), std::ref(x2)}) {
|
||||
for (const auto &f : {std::ref(x1), std::ref(x2)}) {
|
||||
l.append(py::cast(f, copy ? py::return_value_policy::copy
|
||||
: py::return_value_policy::reference));
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ TEST_SUBMODULE(call_policies, m) {
|
||||
// but it's unclear how to test it without `PyGILState_GetThisThreadState`.
|
||||
auto report_gil_status = []() {
|
||||
auto is_gil_held = false;
|
||||
if (auto tstate = py::detail::get_thread_state_unchecked()) {
|
||||
if (auto *tstate = py::detail::get_thread_state_unchecked()) {
|
||||
is_gil_held = (tstate == PyGILState_GetThisThreadState());
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ TEST_SUBMODULE(callbacks, m) {
|
||||
py::arg("expect_none") = false);
|
||||
m.def("test_dummy_function", [](const std::function<int(int)> &f) -> std::string {
|
||||
using fn_type = int (*)(int);
|
||||
auto result = f.target<fn_type>();
|
||||
const auto *result = f.target<fn_type>();
|
||||
if (!result) {
|
||||
auto r = f(1);
|
||||
return "can't convert to function pointer: eval(1) = " + std::to_string(r);
|
||||
|
@ -255,7 +255,7 @@ TEST_SUBMODULE(class_, m) {
|
||||
return py::str().release().ptr();
|
||||
};
|
||||
|
||||
auto def = new PyMethodDef{"f", f, METH_VARARGS, nullptr};
|
||||
auto *def = new PyMethodDef{"f", f, METH_VARARGS, nullptr};
|
||||
py::capsule def_capsule(def, [](void *ptr) { delete reinterpret_cast<PyMethodDef *>(ptr); });
|
||||
return py::reinterpret_steal<py::object>(PyCFunction_NewEx(def, def_capsule.ptr(), m.ptr()));
|
||||
}());
|
||||
|
@ -240,8 +240,8 @@ TEST_CASE("Subinterpreter") {
|
||||
REQUIRE(has_pybind11_internals_static());
|
||||
|
||||
/// Create and switch to a subinterpreter.
|
||||
auto main_tstate = PyThreadState_Get();
|
||||
auto sub_tstate = Py_NewInterpreter();
|
||||
auto *main_tstate = PyThreadState_Get();
|
||||
auto *sub_tstate = Py_NewInterpreter();
|
||||
|
||||
// Subinterpreters get their own copy of builtins. detail::get_internals() still
|
||||
// works by returning from the static variable, i.e. all interpreters share a single
|
||||
|
@ -89,7 +89,7 @@ template<typename... Ix> arr data_t(const arr_t& a, Ix... index) {
|
||||
}
|
||||
|
||||
template<typename... Ix> arr& mutate_data(arr& a, Ix... index) {
|
||||
auto ptr = (uint8_t *) a.mutable_data(index...);
|
||||
auto *ptr = (uint8_t *) a.mutable_data(index...);
|
||||
for (py::ssize_t i = 0; i < a.nbytes() - a.offset_at(index...); i++) {
|
||||
ptr[i] = (uint8_t) (ptr[i] * 2);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ template <typename S>
|
||||
py::array_t<S, 0> create_recarray(size_t n) {
|
||||
auto arr = mkarray_via_buffer<S>(n);
|
||||
auto req = arr.request();
|
||||
auto ptr = static_cast<S*>(req.ptr);
|
||||
auto *ptr = static_cast<S *>(req.ptr);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
SET_TEST_VALS(ptr[i], i);
|
||||
}
|
||||
@ -175,7 +175,7 @@ py::array_t<S, 0> create_recarray(size_t n) {
|
||||
template <typename S>
|
||||
py::list print_recarray(py::array_t<S, 0> arr) {
|
||||
const auto req = arr.request();
|
||||
const auto ptr = static_cast<S*>(req.ptr);
|
||||
auto *const ptr = static_cast<S *>(req.ptr);
|
||||
auto l = py::list();
|
||||
for (py::ssize_t i = 0; i < req.size; i++) {
|
||||
std::stringstream ss;
|
||||
@ -192,8 +192,8 @@ py::array_t<int32_t, 0> test_array_ctors(int i) {
|
||||
std::vector<py::ssize_t> shape { 3, 2 };
|
||||
std::vector<py::ssize_t> strides { 8, 4 };
|
||||
|
||||
auto ptr = data.data();
|
||||
auto vptr = (void *) ptr;
|
||||
auto *ptr = data.data();
|
||||
auto *vptr = (void *) ptr;
|
||||
auto dtype = py::dtype("int32");
|
||||
|
||||
py::buffer_info buf_ndim1(vptr, 4, "i", 6);
|
||||
@ -328,7 +328,7 @@ TEST_SUBMODULE(numpy_dtypes, m) {
|
||||
m.def("create_rec_nested", [](size_t n) { // test_signature
|
||||
py::array_t<NestedStruct, 0> arr = mkarray_via_buffer<NestedStruct>(n);
|
||||
auto req = arr.request();
|
||||
auto ptr = static_cast<NestedStruct*>(req.ptr);
|
||||
auto *ptr = static_cast<NestedStruct *>(req.ptr);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
SET_TEST_VALS(ptr[i].a, i);
|
||||
SET_TEST_VALS(ptr[i].b, i + 1);
|
||||
@ -339,7 +339,7 @@ TEST_SUBMODULE(numpy_dtypes, m) {
|
||||
m.def("create_rec_partial_nested", [](size_t n) {
|
||||
py::array_t<PartialNestedStruct, 0> arr = mkarray_via_buffer<PartialNestedStruct>(n);
|
||||
auto req = arr.request();
|
||||
auto ptr = static_cast<PartialNestedStruct*>(req.ptr);
|
||||
auto *ptr = static_cast<PartialNestedStruct *>(req.ptr);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
SET_TEST_VALS(ptr[i].a, i);
|
||||
}
|
||||
@ -397,14 +397,14 @@ TEST_SUBMODULE(numpy_dtypes, m) {
|
||||
m.def("test_dtype_ctors", &test_dtype_ctors);
|
||||
m.def("test_dtype_kind", [dtype_names]() {
|
||||
py::list list;
|
||||
for (auto &dt_name : dtype_names) {
|
||||
for (const auto &dt_name : dtype_names) {
|
||||
list.append(py::dtype(dt_name).kind());
|
||||
}
|
||||
return list;
|
||||
});
|
||||
m.def("test_dtype_char_", [dtype_names]() {
|
||||
py::list list;
|
||||
for (auto &dt_name : dtype_names) {
|
||||
for (const auto &dt_name : dtype_names) {
|
||||
list.append(py::dtype(dt_name).char_());
|
||||
}
|
||||
return list;
|
||||
@ -430,7 +430,7 @@ TEST_SUBMODULE(numpy_dtypes, m) {
|
||||
py::array_t<StringStruct, 0> arr = mkarray_via_buffer<StringStruct>(non_empty ? 4 : 0);
|
||||
if (non_empty) {
|
||||
auto req = arr.request();
|
||||
auto ptr = static_cast<StringStruct*>(req.ptr);
|
||||
auto *ptr = static_cast<StringStruct *>(req.ptr);
|
||||
for (py::ssize_t i = 0; i < req.size * req.itemsize; i++) {
|
||||
static_cast<char *>(req.ptr)[i] = 0;
|
||||
}
|
||||
@ -450,7 +450,7 @@ TEST_SUBMODULE(numpy_dtypes, m) {
|
||||
// test_array_array
|
||||
m.def("create_array_array", [](size_t n) {
|
||||
py::array_t<ArrayStruct, 0> arr = mkarray_via_buffer<ArrayStruct>(n);
|
||||
auto ptr = (ArrayStruct *) arr.mutable_data();
|
||||
auto *ptr = (ArrayStruct *) arr.mutable_data();
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
for (size_t j = 0; j < 3; j++) {
|
||||
for (size_t k = 0; k < 4; k++) {
|
||||
@ -476,7 +476,7 @@ TEST_SUBMODULE(numpy_dtypes, m) {
|
||||
// test_enum_array
|
||||
m.def("create_enum_array", [](size_t n) {
|
||||
py::array_t<EnumStruct, 0> arr = mkarray_via_buffer<EnumStruct>(n);
|
||||
auto ptr = (EnumStruct *) arr.mutable_data();
|
||||
auto *ptr = (EnumStruct *) arr.mutable_data();
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
ptr[i].e1 = static_cast<E1>(-1 + ((int) i % 2) * 2);
|
||||
ptr[i].e2 = static_cast<E2>(1 + (i % 2));
|
||||
@ -488,7 +488,7 @@ TEST_SUBMODULE(numpy_dtypes, m) {
|
||||
// test_complex_array
|
||||
m.def("create_complex_array", [](size_t n) {
|
||||
py::array_t<ComplexStruct, 0> arr = mkarray_via_buffer<ComplexStruct>(n);
|
||||
auto ptr = (ComplexStruct *) arr.mutable_data();
|
||||
auto *ptr = (ComplexStruct *) arr.mutable_data();
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
ptr[i].cflt.real(float(i));
|
||||
ptr[i].cflt.imag(float(i) + 0.25f);
|
||||
|
@ -146,7 +146,7 @@ TEST_SUBMODULE(pytypes, m) {
|
||||
m.def("return_capsule_with_name_and_destructor", []() {
|
||||
auto capsule = py::capsule((void *) 12345, "pointer type description", [](PyObject *ptr) {
|
||||
if (ptr) {
|
||||
auto name = PyCapsule_GetName(ptr);
|
||||
const auto *name = PyCapsule_GetName(ptr);
|
||||
py::print("destructing capsule ({}, '{}')"_s.format(
|
||||
(size_t) PyCapsule_GetPointer(ptr, name), name
|
||||
));
|
||||
|
@ -113,7 +113,7 @@ public:
|
||||
static void cleanupAllInstances() {
|
||||
auto tmp = std::move(myobject4_instances);
|
||||
myobject4_instances.clear();
|
||||
for (auto o : tmp) {
|
||||
for (auto *o : tmp) {
|
||||
delete o;
|
||||
}
|
||||
}
|
||||
@ -141,7 +141,7 @@ public:
|
||||
static void cleanupAllInstances() {
|
||||
auto tmp = std::move(myobject4a_instances);
|
||||
myobject4a_instances.clear();
|
||||
for (auto o : tmp) {
|
||||
for (auto *o : tmp) {
|
||||
delete o;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
};
|
||||
|
||||
template <class Container> Container *one_to_n(int n) {
|
||||
auto v = new Container();
|
||||
auto *v = new Container();
|
||||
for (int i = 1; i <= n; i++) {
|
||||
v->emplace_back(i);
|
||||
}
|
||||
@ -49,7 +49,7 @@ template <class Container> Container *one_to_n(int n) {
|
||||
}
|
||||
|
||||
template <class Map> Map *times_ten(int n) {
|
||||
auto m = new Map();
|
||||
auto *m = new Map();
|
||||
for (int i = 1; i <= n; i++) {
|
||||
m->emplace(int(i), E_nc(10 * i));
|
||||
}
|
||||
@ -57,7 +57,7 @@ template <class Map> Map *times_ten(int n) {
|
||||
}
|
||||
|
||||
template <class NestMap> NestMap *times_hundred(int n) {
|
||||
auto m = new NestMap();
|
||||
auto *m = new NestMap();
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
(*m)[i].emplace(int(j * 10), E_nc(100 * j));
|
||||
@ -99,16 +99,15 @@ TEST_SUBMODULE(stl_binders, m) {
|
||||
m.def("get_umnc", ×_ten<std::unordered_map<int, E_nc>>);
|
||||
// Issue #1885: binding nested std::map<X, Container<E>> with E non-copyable
|
||||
py::bind_map<std::map<int, std::vector<E_nc>>>(m, "MapVecENC");
|
||||
m.def("get_nvnc", [](int n)
|
||||
{
|
||||
auto m = new std::map<int, std::vector<E_nc>>();
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
(*m)[i].emplace_back(j);
|
||||
}
|
||||
m.def("get_nvnc", [](int n) {
|
||||
auto *m = new std::map<int, std::vector<E_nc>>();
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
(*m)[i].emplace_back(j);
|
||||
}
|
||||
return m;
|
||||
});
|
||||
}
|
||||
return m;
|
||||
});
|
||||
py::bind_map<std::map<int, std::map<int, E_nc>>>(m, "MapMapENC");
|
||||
m.def("get_nmnc", ×_hundred<std::map<int, std::map<int, E_nc>>>);
|
||||
py::bind_map<std::unordered_map<int, std::unordered_map<int, E_nc>>>(m, "UmapUmapENC");
|
||||
|
Loading…
Reference in New Issue
Block a user