@@ -384,6 +384,8 @@ TEST_SUBMODULE(class_, m) {
384
384
385
385
protected:
386
386
virtual int foo () const { return value; }
387
+ virtual void *void_foo () { return static_cast <void *>(&value); }
388
+ virtual void *get_self () { return static_cast <void *>(this ); }
387
389
388
390
private:
389
391
int value = 42 ;
@@ -392,6 +394,8 @@ TEST_SUBMODULE(class_, m) {
392
394
class TrampolineB : public ProtectedB {
393
395
public:
394
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, ); }
395
399
};
396
400
397
401
class PublicistB : public ProtectedB {
@@ -401,11 +405,23 @@ TEST_SUBMODULE(class_, m) {
401
405
// (in Debug builds only, tested with icpc (ICC) 2021.1 Beta 20200827)
402
406
~PublicistB () override {}; // NOLINT(modernize-use-equals-default)
403
407
using ProtectedB::foo;
408
+ using ProtectedB::get_self;
409
+ using ProtectedB::void_foo;
404
410
};
405
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
+
406
420
py::class_<ProtectedB, TrampolineB>(m, " ProtectedB" )
407
421
.def (py::init<>())
408
- .def (" foo" , &PublicistB::foo);
422
+ .def (" foo" , &PublicistB::foo)
423
+ .def (" void_foo" , &PublicistB::void_foo)
424
+ .def (" get_self" , &PublicistB::get_self);
409
425
410
426
// test_brace_initialization
411
427
struct BraceInitialization {
0 commit comments