| 395 | public: |
| 396 | int foo() const override { PYBIND11_OVERRIDE(int, ProtectedB, foo, ); } |
| 397 | void *void_foo() override { PYBIND11_OVERRIDE(void *, ProtectedB, void_foo, ); } |
| 398 | void *get_self() override { PYBIND11_OVERRIDE(void *, ProtectedB, get_self, ); } |
| 399 | }; |
| 400 | |
| 401 | class PublicistB : public ProtectedB { |
| 402 | public: |
| 403 | // [workaround(intel)] = default does not work here |
| 404 | // Removing or defaulting this destructor results in linking errors with the Intel compiler |
| 405 | // (in Debug builds only, tested with icpc (ICC) 2021.1 Beta 20200827) |
| 406 | ~PublicistB() override {}; // NOLINT(modernize-use-equals-default) |
| 407 | using ProtectedB::foo; |
| 408 | using ProtectedB::get_self; |
| 409 | using ProtectedB::void_foo; |
| 410 | }; |
| 411 | |
| 412 | m.def("read_foo", [](const void *original) { |
| 413 | const int *ptr = reinterpret_cast<const int *>(original); |
| 414 | return *ptr; |
| 415 | }); |
| 416 | |
| 417 | m.def("pointers_equal", |
| 418 | [](const void *original, const void *comparison) { return original == comparison; }); |
| 419 | |
| 420 | py::class_<ProtectedB, TrampolineB>(m, "ProtectedB") |
| 421 | .def(py::init<>()) |
| 422 | .def("foo", &PublicistB::foo) |
| 423 | .def("void_foo", &PublicistB::void_foo) |
| 424 | .def("get_self", &PublicistB::get_self); |
| 425 | |
| 426 | // test_brace_initialization |
| 427 | struct BraceInitialization { |
| 428 | int field1; |
| 429 | std::string field2; |
| 430 | }; |
| 431 | |
| 432 | py::class_<BraceInitialization>(m, "BraceInitialization") |
| 433 | .def(py::init<int, const std::string &>()) |
| 434 | .def_readwrite("field1", &BraceInitialization::field1) |
| 435 | .def_readwrite("field2", &BraceInitialization::field2); |
| 436 | // We *don't* want to construct using braces when the given constructor argument maps to a |
| 437 | // constructor, because brace initialization could go to the wrong place (in particular when |
| 438 | // there is also an `initializer_list<T>`-accept constructor): |
| 439 | py::class_<NoBraceInitialization>(m, "NoBraceInitialization") |
| 440 | .def(py::init<std::vector<int>>()) |
| 441 | .def_readonly("vec", &NoBraceInitialization::vec); |
| 442 | |
| 443 | // test_reentrant_implicit_conversion_failure |
| 444 | // #1035: issue with runaway reentrant implicit conversion |
| 445 | struct BogusImplicitConversion { |
| 446 | BogusImplicitConversion(const BogusImplicitConversion &) = default; |
| 447 | }; |
| 448 | |
| 449 | py::class_<BogusImplicitConversion>(m, "BogusImplicitConversion") |
| 450 | .def(py::init<const BogusImplicitConversion &>()); |
| 451 | |
| 452 | py::implicitly_convertible<int, BogusImplicitConversion>(); |
| 453 | |
| 454 | // test_qualname |
nothing calls this directly
no test coverage detected