mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 07:02:11 +00:00
Applying clang-tidy fixes needed after merging PR #3051 (mostly automatically).
This commit is contained in:
parent
898d5b301c
commit
2eeac0c369
@ -14,7 +14,7 @@ struct atyp { // Short for "any type".
|
||||
atyp() : mtxt("DefaultConstructor") {}
|
||||
atyp(const std::string &mtxt_) : mtxt(mtxt_) {}
|
||||
atyp(const atyp &other) { mtxt = other.mtxt + "_CpCtor"; }
|
||||
atyp(atyp &&other) { mtxt = other.mtxt + "_MvCtor"; }
|
||||
atyp(atyp &&other) noexcept { mtxt = other.mtxt + "_MvCtor"; }
|
||||
};
|
||||
|
||||
struct uconsumer { // unique_ptr consumer
|
||||
@ -37,7 +37,7 @@ atyp& rtrn_mref() { static atyp obj; obj.mtxt = "rtrn_mref"; return obj; }
|
||||
atyp const* rtrn_cptr() { return new atyp{"rtrn_cptr"}; }
|
||||
atyp* rtrn_mptr() { return new atyp{"rtrn_mptr"}; }
|
||||
|
||||
std::string pass_valu(atyp obj) { return "pass_valu:" + obj.mtxt; }
|
||||
std::string pass_valu(atyp obj) { return "pass_valu:" + obj.mtxt; } // NOLINT
|
||||
std::string pass_cref(atyp const& obj) { return "pass_cref:" + obj.mtxt; }
|
||||
std::string pass_mref(atyp& obj) { return "pass_mref:" + obj.mtxt; }
|
||||
std::string pass_cptr(atyp const* obj) { return "pass_cptr:" + obj->mtxt; }
|
||||
@ -46,8 +46,8 @@ std::string pass_mptr(atyp* obj) { return "pass_mptr:" + obj->mtxt; }
|
||||
std::shared_ptr<atyp> rtrn_shmp() { return std::shared_ptr<atyp >(new atyp{"rtrn_shmp"}); }
|
||||
std::shared_ptr<atyp const> rtrn_shcp() { return std::shared_ptr<atyp const>(new atyp{"rtrn_shcp"}); }
|
||||
|
||||
std::string pass_shmp(std::shared_ptr<atyp> obj) { return "pass_shmp:" + obj->mtxt; }
|
||||
std::string pass_shcp(std::shared_ptr<atyp const> obj) { return "pass_shcp:" + obj->mtxt; }
|
||||
std::string pass_shmp(std::shared_ptr<atyp> obj) { return "pass_shmp:" + obj->mtxt; } // NOLINT
|
||||
std::string pass_shcp(std::shared_ptr<atyp const> obj) { return "pass_shcp:" + obj->mtxt; } // NOLINT
|
||||
|
||||
std::unique_ptr<atyp> rtrn_uqmp() { return std::unique_ptr<atyp >(new atyp{"rtrn_uqmp"}); }
|
||||
std::unique_ptr<atyp const> rtrn_uqcp() { return std::unique_ptr<atyp const>(new atyp{"rtrn_uqcp"}); }
|
||||
@ -77,7 +77,7 @@ const std::unique_ptr<atyp> &unique_ptr_cref_roundtrip(const std::unique_ptr<aty
|
||||
|
||||
struct SharedPtrStash {
|
||||
std::vector<std::shared_ptr<const atyp>> stash;
|
||||
void Add(std::shared_ptr<const atyp> obj) { stash.push_back(obj); }
|
||||
void Add(const std::shared_ptr<const atyp> &obj) { stash.push_back(obj); }
|
||||
};
|
||||
|
||||
} // namespace class_sh_basic
|
||||
|
@ -15,10 +15,10 @@ struct base_template {
|
||||
int base_id;
|
||||
|
||||
// Some compilers complain about implicitly defined versions of some of the following:
|
||||
base_template(const base_template &) = default;
|
||||
base_template(base_template &&) = default;
|
||||
base_template(const base_template &) = default;
|
||||
base_template(base_template &&) noexcept = default;
|
||||
base_template &operator=(const base_template &) = default;
|
||||
base_template &operator=(base_template &&) = default;
|
||||
base_template &operator=(base_template &&) noexcept = default;
|
||||
};
|
||||
|
||||
using base = base_template<100>;
|
||||
@ -37,8 +37,8 @@ inline int pass_cptr_drvd(drvd const *d) { return d->id() + 12; }
|
||||
inline std::shared_ptr<drvd> rtrn_shmp_drvd() { return std::shared_ptr<drvd>(new drvd); }
|
||||
inline std::shared_ptr<base> rtrn_shmp_drvd_up_cast() { return std::shared_ptr<drvd>(new drvd); }
|
||||
|
||||
inline int pass_shcp_base(std::shared_ptr<base const> b) { return b->id() + 21; }
|
||||
inline int pass_shcp_drvd(std::shared_ptr<drvd const> d) { return d->id() + 22; }
|
||||
inline int pass_shcp_base(const std::shared_ptr<base const>& b) { return b->id() + 21; }
|
||||
inline int pass_shcp_drvd(const std::shared_ptr<drvd const>& d) { return d->id() + 22; }
|
||||
// clang-format on
|
||||
|
||||
using base1 = base_template<110>;
|
||||
|
@ -16,10 +16,10 @@ struct Abase {
|
||||
virtual int Add(int other_val) const = 0;
|
||||
|
||||
// Some compilers complain about implicitly defined versions of some of the following:
|
||||
Abase(const Abase &) = default;
|
||||
Abase(Abase &&) = default;
|
||||
Abase(const Abase &) = default;
|
||||
Abase(Abase &&) noexcept = default;
|
||||
Abase &operator=(const Abase &) = default;
|
||||
Abase &operator=(Abase &&) = default;
|
||||
Abase &operator=(Abase &&) noexcept = default;
|
||||
};
|
||||
|
||||
template <int SerNo>
|
||||
|
@ -8,24 +8,25 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace {
|
||||
|
||||
struct Big5 { // Also known as "rule of five".
|
||||
std::string history;
|
||||
|
||||
explicit Big5(std::string history_start) : history{history_start} {}
|
||||
explicit Big5(std::string history_start) : history{std::move(history_start)} {}
|
||||
|
||||
Big5(const Big5 &other) { history = other.history + "_CpCtor"; }
|
||||
|
||||
Big5(Big5 &&other) { history = other.history + "_MvCtor"; }
|
||||
Big5(Big5 &&other) noexcept { history = other.history + "_MvCtor"; }
|
||||
|
||||
Big5 &operator=(const Big5 &other) {
|
||||
history = other.history + "_OpEqLv";
|
||||
return *this;
|
||||
}
|
||||
|
||||
Big5 &operator=(Big5 &&other) {
|
||||
Big5 &operator=(Big5 &&other) noexcept {
|
||||
history = other.history + "_OpEqRv";
|
||||
return *this;
|
||||
}
|
||||
|
@ -2,8 +2,10 @@
|
||||
// All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "pybind11_tests.h"
|
||||
#include <utility>
|
||||
|
||||
#include "pybind11/smart_holder.h"
|
||||
#include "pybind11_tests.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -16,7 +18,7 @@ struct SpBase {
|
||||
// returns true if there's an associated python instance
|
||||
bool has_python_instance() {
|
||||
auto tinfo = py::detail::get_type_info(typeid(SpBase));
|
||||
return (bool)py::detail::get_object_handle(this, tinfo);
|
||||
return (bool) py::detail::get_object_handle(this, tinfo);
|
||||
}
|
||||
|
||||
SpBase() = default;
|
||||
@ -30,13 +32,11 @@ struct PySpBase : SpBase {
|
||||
|
||||
struct SpBaseTester {
|
||||
std::shared_ptr<SpBase> get_object() const { return m_obj; }
|
||||
void set_object(std::shared_ptr<SpBase> obj) { m_obj = obj; }
|
||||
void set_object(std::shared_ptr<SpBase> obj) { m_obj = std::move(obj); }
|
||||
bool is_base_used() { return m_obj->is_base_used(); }
|
||||
bool has_instance() { return (bool)m_obj; }
|
||||
bool has_instance() { return (bool) m_obj; }
|
||||
bool has_python_instance() { return m_obj && m_obj->has_python_instance(); }
|
||||
void set_nonpython_instance() {
|
||||
m_obj = std::make_shared<SpBase>();
|
||||
}
|
||||
void set_nonpython_instance() { m_obj = std::make_shared<SpBase>(); }
|
||||
std::shared_ptr<SpBase> m_obj;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user