mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-31 15:20:34 +00:00
clang-tidy fixes related to PR #3250
This commit is contained in:
parent
94a5c673bc
commit
b4e1ac9a94
@ -1,8 +1,8 @@
|
||||
assert m.atyp_valu().get_mtxt() == "Valu"
|
||||
atyp_valu rtrn_valu() { atyp_valu obj{"Valu"}; return obj; }
|
||||
indestructible_int(int v) : valu{v} {}
|
||||
explicit indestructible_int(int v) : valu{v} {}
|
||||
explicit movable_int(int v) : valu{v} {}
|
||||
int valu;
|
||||
movable_int(int v) : valu{v} {}
|
||||
(m.pass_valu, "Valu", "pass_valu:Valu(_MvCtor)*_CpCtor"),
|
||||
other.valu = 91;
|
||||
REQUIRE(hld.as_raw_ptr_unowned<zombie>()->valu == 19);
|
||||
|
@ -43,7 +43,7 @@ inline bool deregister_instance(instance *self, void *valptr, const type_info *t
|
||||
// clang-format off
|
||||
class modified_type_caster_generic_load_impl {
|
||||
public:
|
||||
PYBIND11_NOINLINE modified_type_caster_generic_load_impl(const std::type_info &type_info)
|
||||
PYBIND11_NOINLINE explicit modified_type_caster_generic_load_impl(const std::type_info &type_info)
|
||||
: typeinfo(get_type_info(type_info)), cpptype(&type_info) { }
|
||||
|
||||
explicit modified_type_caster_generic_load_impl(const type_info *typeinfo = nullptr)
|
||||
@ -598,13 +598,17 @@ struct smart_holder_type_caster : smart_holder_type_caster_load<T>,
|
||||
// The const operators here prove that the existing type_caster mechanism already supports
|
||||
// const-correctness. However, fully implementing const-correctness inside this type_caster
|
||||
// is still a major project.
|
||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||
operator T const &() const {
|
||||
return const_cast<smart_holder_type_caster *>(this)->loaded_as_lvalue_ref();
|
||||
}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||
operator T const *() const {
|
||||
return const_cast<smart_holder_type_caster *>(this)->loaded_as_raw_ptr_unowned();
|
||||
}
|
||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||
operator T &() { return this->loaded_as_lvalue_ref(); }
|
||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||
operator T *() { return this->loaded_as_raw_ptr_unowned(); }
|
||||
|
||||
// Originally type_caster_generic::cast.
|
||||
@ -749,6 +753,7 @@ struct smart_holder_type_caster<std::shared_ptr<T>> : smart_holder_type_caster_l
|
||||
template <typename>
|
||||
using cast_op_type = std::shared_ptr<T>;
|
||||
|
||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||
operator std::shared_ptr<T>() { return this->loaded_as_shared_ptr(); }
|
||||
};
|
||||
|
||||
@ -768,6 +773,7 @@ struct smart_holder_type_caster<std::shared_ptr<T const>> : smart_holder_type_ca
|
||||
template <typename>
|
||||
using cast_op_type = std::shared_ptr<T const>;
|
||||
|
||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||
operator std::shared_ptr<T const>() { return this->loaded_as_shared_ptr(); } // Mutbl2Const
|
||||
};
|
||||
|
||||
@ -844,6 +850,7 @@ struct smart_holder_type_caster<std::unique_ptr<T, D>> : smart_holder_type_caste
|
||||
template <typename>
|
||||
using cast_op_type = std::unique_ptr<T, D>;
|
||||
|
||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||
operator std::unique_ptr<T, D>() { return this->template loaded_as_unique_ptr<D>(); }
|
||||
};
|
||||
|
||||
@ -863,6 +870,7 @@ struct smart_holder_type_caster<std::unique_ptr<T const, D>>
|
||||
template <typename>
|
||||
using cast_op_type = std::unique_ptr<T const, D>;
|
||||
|
||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||
operator std::unique_ptr<T const, D>() { return this->template loaded_as_unique_ptr<D>(); }
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,7 @@ namespace helpers {
|
||||
|
||||
struct movable_int {
|
||||
int valu;
|
||||
movable_int(int v) : valu{v} {}
|
||||
explicit movable_int(int v) : valu{v} {}
|
||||
movable_int(movable_int &&other) noexcept {
|
||||
valu = other.valu;
|
||||
other.valu = 91;
|
||||
@ -26,7 +26,7 @@ struct functor_other_delete : functor_builtin_delete<T> {};
|
||||
|
||||
struct indestructible_int {
|
||||
int valu;
|
||||
indestructible_int(int v) : valu{v} {}
|
||||
explicit indestructible_int(int v) : valu{v} {}
|
||||
|
||||
private:
|
||||
~indestructible_int() = default;
|
||||
|
@ -12,7 +12,7 @@ namespace class_sh_basic {
|
||||
struct atyp { // Short for "any type".
|
||||
std::string mtxt;
|
||||
atyp() : mtxt("DefaultConstructor") {}
|
||||
atyp(const std::string &mtxt_) : mtxt(mtxt_) {}
|
||||
explicit atyp(const std::string &mtxt_) : mtxt(mtxt_) {}
|
||||
atyp(const atyp &other) { mtxt = other.mtxt + "_CpCtor"; }
|
||||
atyp(atyp &&other) noexcept { mtxt = other.mtxt + "_MvCtor"; }
|
||||
};
|
||||
|
@ -10,7 +10,7 @@ namespace class_sh_disowning {
|
||||
template <int SerNo> // Using int as a trick to easily generate a series of types.
|
||||
struct Atype {
|
||||
int val = 0;
|
||||
Atype(int val_) : val{val_} {}
|
||||
explicit Atype(int val_) : val{val_} {}
|
||||
int get() const { return val * 10 + SerNo; }
|
||||
};
|
||||
|
||||
|
@ -31,13 +31,13 @@ void disown_b(std::unique_ptr<B>) {}
|
||||
|
||||
// test_multiple_inheritance_python
|
||||
struct Base1 {
|
||||
Base1(int i) : i(i) {}
|
||||
explicit Base1(int i) : i(i) {}
|
||||
int foo() const { return i; }
|
||||
int i;
|
||||
};
|
||||
|
||||
struct Base2 {
|
||||
Base2(int j) : j(j) {}
|
||||
explicit Base2(int j) : j(j) {}
|
||||
int bar() const { return j; }
|
||||
int j;
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ const std::string fooNames[] = {"ShPtr_", "SmHld_"};
|
||||
template <int SerNo>
|
||||
struct Foo {
|
||||
std::string history;
|
||||
Foo(const std::string &history_) : history(history_) {}
|
||||
explicit Foo(const std::string &history_) : history(history_) {}
|
||||
Foo(const Foo &other) : history(other.history + "_CpCtor") {}
|
||||
Foo(Foo &&other) noexcept : history(other.history + "_MvCtor") {}
|
||||
Foo &operator=(const Foo &other) {
|
||||
|
@ -11,7 +11,7 @@ template <int SerNo> // Using int as a trick to easily generate a series of type
|
||||
struct Abase {
|
||||
int val = 0;
|
||||
virtual ~Abase() = default;
|
||||
Abase(int val_) : val{val_} {}
|
||||
explicit Abase(int val_) : val{val_} {}
|
||||
int Get() const { return val * 10 + 3; }
|
||||
virtual int Add(int other_val) const = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user