mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 06:49:25 +00:00
CodeHealth: Enabling clang-tidy google-explicit-constructor (#3250)
* Adding google-explicit-constructor to .clang-tidy * clang-tidy explicit attr.h (all automatic) * clang-tidy explicit cast.h (all automatic) * clang-tidy detail/init.h (1 NOLINT) * clang-tidy detail/type_caster_base.h (2 NOLINT) * clang-tidy pybind11.h (7 NOLINT) * clang-tidy detail/common.h (3 NOLINT) * clang-tidy detail/descr.h (2 NOLINT) * clang-tidy pytypes.h (23 NOLINT, only 1 explicit) * clang-tidy eigen.h (7 NOLINT, 0 explicit) * Adding 2 explicit in functional.h * Adding 4 explicit in iostream.h * clang-tidy numpy.h (1 NOLINT, 1 explicit) * clang-tidy embed.h (0 NOLINT, 1 explicit) * clang-tidy tests/local_bindings.h (0 NOLINT, 4 explicit) * clang-tidy tests/pybind11_cross_module_tests.cpp (0 NOLINT, 1 explicit) * clang-tidy tests/pybind11_tests.h (0 NOLINT, 2 explicit) * clang-tidy tests/test_buffers.cpp (0 NOLINT, 2 explicit) * clang-tidy tests/test_builtin_casters.cpp (0 NOLINT, 4 explicit) * clang-tidy tests/test_class.cpp (0 NOLINT, 6 explicit) * clang-tidy tests/test_copy_move.cpp (0 NOLINT, 7 explicit) * clang-tidy tests/test_embed/external_module.cpp (0 NOLINT, 1 explicit) * clang-tidy tests/test_embed/test_interpreter.cpp (0 NOLINT, 1 explicit) * clang-tidy tests/object.h (0 NOLINT, 2 explicit) * clang-tidy batch of fully automatic fixes. * Workaround for MSVC 19.16.27045.0 C++17 Python 2 C++ syntax error.
This commit is contained in:
committed by
GitHub
parent
39a0aac88e
commit
6abf2baa62
@@ -20,7 +20,7 @@ template<typename T>
|
||||
class NonZeroIterator {
|
||||
const T* ptr_;
|
||||
public:
|
||||
NonZeroIterator(const T* ptr) : ptr_(ptr) {}
|
||||
explicit NonZeroIterator(const T *ptr) : ptr_(ptr) {}
|
||||
const T& operator*() const { return *ptr_; }
|
||||
NonZeroIterator& operator++() { ++ptr_; return *this; }
|
||||
};
|
||||
@@ -77,9 +77,9 @@ TEST_SUBMODULE(sequences_and_iterators, m) {
|
||||
// test_sliceable
|
||||
class Sliceable{
|
||||
public:
|
||||
Sliceable(int n): size(n) {}
|
||||
int start,stop,step;
|
||||
int size;
|
||||
explicit Sliceable(int n) : size(n) {}
|
||||
int start, stop, step;
|
||||
int size;
|
||||
};
|
||||
py::class_<Sliceable>(m, "Sliceable")
|
||||
.def(py::init<int>())
|
||||
@@ -96,12 +96,12 @@ TEST_SUBMODULE(sequences_and_iterators, m) {
|
||||
// test_sequence
|
||||
class Sequence {
|
||||
public:
|
||||
Sequence(size_t size) : m_size(size) {
|
||||
explicit Sequence(size_t size) : m_size(size) {
|
||||
print_created(this, "of size", m_size);
|
||||
m_data = new float[size];
|
||||
memset(m_data, 0, sizeof(float) * size);
|
||||
}
|
||||
Sequence(const std::vector<float> &value) : m_size(value.size()) {
|
||||
explicit Sequence(const std::vector<float> &value) : m_size(value.size()) {
|
||||
print_created(this, "of size", m_size, "from std::vector");
|
||||
m_data = new float[m_size];
|
||||
memcpy(m_data, &value[0], sizeof(float) * m_size);
|
||||
@@ -239,7 +239,7 @@ TEST_SUBMODULE(sequences_and_iterators, m) {
|
||||
class StringMap {
|
||||
public:
|
||||
StringMap() = default;
|
||||
StringMap(std::unordered_map<std::string, std::string> init)
|
||||
explicit StringMap(std::unordered_map<std::string, std::string> init)
|
||||
: map(std::move(init)) {}
|
||||
|
||||
void set(const std::string &key, std::string val) { map[key] = std::move(val); }
|
||||
@@ -276,7 +276,7 @@ TEST_SUBMODULE(sequences_and_iterators, m) {
|
||||
// test_generalized_iterators
|
||||
class IntPairs {
|
||||
public:
|
||||
IntPairs(std::vector<std::pair<int, int>> data) : data_(std::move(data)) {}
|
||||
explicit IntPairs(std::vector<std::pair<int, int>> data) : data_(std::move(data)) {}
|
||||
const std::pair<int, int>* begin() const { return data_.data(); }
|
||||
private:
|
||||
std::vector<std::pair<int, int>> data_;
|
||||
|
||||
Reference in New Issue
Block a user