@@ -225,7 +225,7 @@ struct value_and_holder {
225225 value_and_holder () = default ;
226226
227227 // Used for past-the-end iterator
228- value_and_holder (size_t index) : index{index} {}
228+ explicit value_and_holder (size_t index) : index{index} {}
229229
230230 template <typename V = void > V *&value_ptr () const {
231231 return reinterpret_cast <V *&>(vh[0 ]);
@@ -274,7 +274,8 @@ struct values_and_holders {
274274 const type_vec &tinfo;
275275
276276public:
277- values_and_holders (instance *inst) : inst{inst}, tinfo(all_type_info(Py_TYPE(inst))) {}
277+ explicit values_and_holders (instance *inst)
278+ : inst{inst}, tinfo(all_type_info(Py_TYPE(inst))) {}
278279
279280 struct iterator {
280281 private:
@@ -290,7 +291,8 @@ struct values_and_holders {
290291 0 /* index */ )
291292 {}
292293 // Past-the-end iterator:
293- iterator (size_t end) : curr(end) {}
294+ explicit iterator (size_t end) : curr(end) {}
295+
294296 public:
295297 bool operator ==(const iterator &other) const { return curr.index == other.curr .index ; }
296298 bool operator !=(const iterator &other) const { return curr.index != other.curr .index ; }
@@ -491,11 +493,11 @@ inline PyObject *make_new_instance(PyTypeObject *type);
491493
492494class type_caster_generic {
493495public:
494- PYBIND11_NOINLINE type_caster_generic (const std::type_info &type_info)
495- : typeinfo(get_type_info(type_info)), cpptype(&type_info) { }
496+ PYBIND11_NOINLINE explicit type_caster_generic (const std::type_info &type_info)
497+ : typeinfo(get_type_info(type_info)), cpptype(&type_info) {}
496498
497- type_caster_generic (const type_info *typeinfo)
498- : typeinfo(typeinfo), cpptype(typeinfo ? typeinfo->cpptype : nullptr ) { }
499+ explicit type_caster_generic (const type_info *typeinfo)
500+ : typeinfo(typeinfo), cpptype(typeinfo ? typeinfo->cpptype : nullptr ) {}
499501
500502 bool load (handle src, bool convert) {
501503 return load_impl<type_caster_generic>(src, convert);
@@ -923,7 +925,9 @@ template <typename type> class type_caster_base : public type_caster_generic {
923925
924926 template <typename T> using cast_op_type = detail::cast_op_type<T>;
925927
928+ // NOLINTNEXTLINE(google-explicit-constructor)
926929 operator itype*() { return (type *) value; }
930+ // NOLINTNEXTLINE(google-explicit-constructor)
927931 operator itype&() { if (!value) throw reference_cast_error (); return *((itype *) value); }
928932
929933protected:
0 commit comments