@@ -94,6 +94,8 @@ std::shared_ptr<Sft> make_pure_cpp_sft_shd_ptr(const std::string &history_seed)
94
94
return std::make_shared<Sft>(history_seed);
95
95
}
96
96
97
+ std::shared_ptr<Sft> pass_through_shd_ptr (const std::shared_ptr<Sft> &obj) { return obj; }
98
+
97
99
} // namespace
98
100
99
101
PYBIND11_SMART_HOLDER_TYPE_CASTERS (Sft)
@@ -102,7 +104,9 @@ PYBIND11_SMART_HOLDER_TYPE_CASTERS(SftSharedPtrStash)
102
104
TEST_SUBMODULE(class_sh_trampoline_shared_from_this, m) {
103
105
py::classh<Sft, SftTrampoline>(m, " Sft" )
104
106
.def (py::init<std::string>())
105
- .def_readonly (" history" , &Sft::history);
107
+ .def_readonly (" history" , &Sft::history)
108
+ // This leads to multiple entries in registered_instances:
109
+ .def (py::init ([](const std::shared_ptr<Sft> &existing) { return existing; }));
106
110
107
111
py::classh<SftSharedPtrStash>(m, " SftSharedPtrStash" )
108
112
.def (py::init<int >())
@@ -118,4 +122,5 @@ TEST_SUBMODULE(class_sh_trampoline_shared_from_this, m) {
118
122
m.def (" make_pure_cpp_sft_raw_ptr" , make_pure_cpp_sft_raw_ptr);
119
123
m.def (" make_pure_cpp_sft_unq_ptr" , make_pure_cpp_sft_unq_ptr);
120
124
m.def (" make_pure_cpp_sft_shd_ptr" , make_pure_cpp_sft_shd_ptr);
125
+ m.def (" pass_through_shd_ptr" , pass_through_shd_ptr);
121
126
}
0 commit comments