Skip to content

Commit b491b46

Browse files
committed
style: clang-tidy: modernize-use-equals-default
1 parent b342c37 commit b491b46

File tree

10 files changed

+17
-15
lines changed

10 files changed

+17
-15
lines changed

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ llvm-namespace-comment,
66
modernize-use-override,
77
readability-container-size-empty,
88
modernize-use-using,
9+
modernize-use-equals-default,
910
'
1011

1112
HeaderFilterRegex: 'pybind11/.*h'

include/pybind11/attr.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ struct sibling { handle value; sibling(const handle &value) : value(value.ptr())
4040

4141
/// Annotation indicating that a class derives from another given type
4242
template <typename T> struct base {
43+
4344
PYBIND11_DEPRECATED("base<T>() was deprecated in favor of specifying 'T' as a template argument to class_")
44-
base() { }
45+
base() { } // NOLINT(modernize-use-equals-default): breaks MSVC 2015 when adding an attribute
4546
};
4647

4748
/// Keep patient alive while nurse lives
@@ -61,7 +62,7 @@ struct metaclass {
6162
handle value;
6263

6364
PYBIND11_DEPRECATED("py::metaclass() is no longer required. It's turned on by default now.")
64-
metaclass() {}
65+
metaclass() { } // NOLINT(modernize-use-equals-default): breaks MSVC 2015 when adding an attribute
6566

6667
/// Override pybind11's default metaclass
6768
explicit metaclass(handle value) : value(value) { }

include/pybind11/buffer_info.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct buffer_info {
2424
std::vector<ssize_t> strides; // Number of bytes between adjacent entries (for each per dimension)
2525
bool readonly = false; // flag to indicate if the underlying storage may be written to
2626

27-
buffer_info() { }
27+
buffer_info() = default;
2828

2929
buffer_info(void *ptr, ssize_t itemsize, const std::string &format, ssize_t ndim,
3030
detail::any_container<ssize_t> shape_in, detail::any_container<ssize_t> strides_in, bool readonly=false)

include/pybind11/cast.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ struct value_and_holder {
220220
{}
221221

222222
// Default constructor (used to signal a value-and-holder not found by get_value_and_holder())
223-
value_and_holder() {}
223+
value_and_holder() = default;
224224

225225
// Used for past-the-end iterator
226226
value_and_holder(size_t index) : index{index} {}

include/pybind11/detail/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ struct nodelete { template <typename T> void operator()(T*) { } };
761761
PYBIND11_NAMESPACE_BEGIN(detail)
762762
template <typename... Args>
763763
struct overload_cast_impl {
764-
constexpr overload_cast_impl() {} // MSVC 2015 needs this
764+
constexpr overload_cast_impl() {}; // NOLINT(modernize-use-equals-default): MSVC 2015 needs this
765765

766766
template <typename Return>
767767
constexpr auto operator()(Return (*pf)(Args...)) const noexcept

include/pybind11/pybind11.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
5555
/// Wraps an arbitrary C++ function/method/lambda function/.. into a callable Python object
5656
class cpp_function : public function {
5757
public:
58-
cpp_function() { }
58+
cpp_function() = default;
5959
cpp_function(std::nullptr_t) { }
6060

6161
/// Construct a cpp_function from a vanilla function pointer

tests/test_class.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ TEST_SUBMODULE(class_, m) {
103103
BaseClass() = default;
104104
BaseClass(const BaseClass &) = default;
105105
BaseClass(BaseClass &&) = default;
106-
virtual ~BaseClass() {}
106+
virtual ~BaseClass() = default;
107107
};
108108
struct DerivedClass1 : BaseClass { };
109109
struct DerivedClass2 : BaseClass { };
@@ -353,7 +353,7 @@ TEST_SUBMODULE(class_, m) {
353353
// test_reentrant_implicit_conversion_failure
354354
// #1035: issue with runaway reentrant implicit conversion
355355
struct BogusImplicitConversion {
356-
BogusImplicitConversion(const BogusImplicitConversion &) { }
356+
BogusImplicitConversion(const BogusImplicitConversion &) = default;
357357
};
358358

359359
py::class_<BogusImplicitConversion>(m, "BogusImplicitConversion")
@@ -407,7 +407,7 @@ TEST_SUBMODULE(class_, m) {
407407
py::class_<IsNonFinalFinal>(m, "IsNonFinalFinal", py::is_final());
408408

409409
struct PyPrintDestructor {
410-
PyPrintDestructor() {}
410+
PyPrintDestructor() = default;
411411
~PyPrintDestructor() {
412412
py::print("Print from destructor");
413413
}

tests/test_copy_move.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ struct empty {
1919
};
2020

2121
struct lacking_copy_ctor : public empty<lacking_copy_ctor> {
22-
lacking_copy_ctor() {}
22+
lacking_copy_ctor() = default;
2323
lacking_copy_ctor(const lacking_copy_ctor& other) = delete;
2424
};
2525

2626
template <> lacking_copy_ctor empty<lacking_copy_ctor>::instance_ = {};
2727

2828
struct lacking_move_ctor : public empty<lacking_move_ctor> {
29-
lacking_move_ctor() {}
29+
lacking_move_ctor() = default;
3030
lacking_move_ctor(const lacking_move_ctor& other) = delete;
3131
lacking_move_ctor(lacking_move_ctor&& other) = delete;
3232
};

tests/test_smart_ptr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ TEST_SUBMODULE(smart_ptr, m) {
339339
// test_shared_ptr_gc
340340
// #187: issue involving std::shared_ptr<> return value policy & garbage collection
341341
struct ElementBase {
342-
virtual ~ElementBase() { } /* Force creation of virtual table */
342+
virtual ~ElementBase() = default; /* Force creation of virtual table */
343343
ElementBase() = default;
344344
ElementBase(const ElementBase&) = delete;
345345
};

tests/test_virtual_functions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class Movable {
129129

130130
class NCVirt {
131131
public:
132-
virtual ~NCVirt() { }
132+
virtual ~NCVirt() = default;
133133
NCVirt() = default;
134134
NCVirt(const NCVirt&) = delete;
135135
virtual NonCopyable get_noncopyable(int a, int b) { return NonCopyable(a, b); }
@@ -227,7 +227,7 @@ TEST_SUBMODULE(virtual_functions, m) {
227227
struct A {
228228
A() = default;
229229
A(const A&) = delete;
230-
virtual ~A() {}
230+
virtual ~A() = default;
231231
virtual void f() { py::print("A.f()"); }
232232
};
233233

@@ -255,7 +255,7 @@ TEST_SUBMODULE(virtual_functions, m) {
255255
struct A2 {
256256
A2() = default;
257257
A2(const A2&) = delete;
258-
virtual ~A2() {}
258+
virtual ~A2() = default;
259259
virtual void f() { py::print("A2.f()"); }
260260
};
261261

0 commit comments

Comments
 (0)