chore: use explicit defaulting in pyobject macros (#4017)

* Use equals default in pyobject macros

* Remove extra semicolon

* Update clang-tidy equals-default rule to not ignore macros

* Fix formatting

* One last formatting change
This commit is contained in:
Aaron Gokaslan 2022-07-20 12:02:20 -04:00 committed by GitHub
parent f47f1edfe8
commit 42b54507ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -63,6 +63,8 @@ Checks: |
-bugprone-unused-raii, -bugprone-unused-raii,
CheckOptions: CheckOptions:
- key: modernize-use-equals-default.IgnoreMacros
value: false
- key: performance-for-range-copy.WarnOnAllAutoCopies - key: performance-for-range-copy.WarnOnAllAutoCopies
value: true value: true
- key: performance-inefficient-string-concatenation.StrictMode - key: performance-inefficient-string-concatenation.StrictMode

View File

@ -537,7 +537,7 @@ PYBIND11_NAMESPACE_END(detail)
class dtype : public object { class dtype : public object {
public: public:
PYBIND11_OBJECT_DEFAULT(dtype, object, detail::npy_api::get().PyArrayDescr_Check_); PYBIND11_OBJECT_DEFAULT(dtype, object, detail::npy_api::get().PyArrayDescr_Check_)
explicit dtype(const buffer_info &info) { explicit dtype(const buffer_info &info) {
dtype descr(_dtype_from_pep3118()(pybind11::str(info.format))); dtype descr(_dtype_from_pep3118()(pybind11::str(info.format)));

View File

@ -1283,7 +1283,7 @@ public:
#define PYBIND11_OBJECT_CVT_DEFAULT(Name, Parent, CheckFun, ConvertFun) \ #define PYBIND11_OBJECT_CVT_DEFAULT(Name, Parent, CheckFun, ConvertFun) \
PYBIND11_OBJECT_CVT(Name, Parent, CheckFun, ConvertFun) \ PYBIND11_OBJECT_CVT(Name, Parent, CheckFun, ConvertFun) \
Name() : Parent() {} Name() = default;
#define PYBIND11_OBJECT_CHECK_FAILED(Name, o_ptr) \ #define PYBIND11_OBJECT_CHECK_FAILED(Name, o_ptr) \
::pybind11::type_error("Object of type '" \ ::pybind11::type_error("Object of type '" \
@ -1306,7 +1306,7 @@ public:
#define PYBIND11_OBJECT_DEFAULT(Name, Parent, CheckFun) \ #define PYBIND11_OBJECT_DEFAULT(Name, Parent, CheckFun) \
PYBIND11_OBJECT(Name, Parent, CheckFun) \ PYBIND11_OBJECT(Name, Parent, CheckFun) \
Name() : Parent() {} Name() = default;
/// \addtogroup pytypes /// \addtogroup pytypes
/// @{ /// @{