File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -1448,17 +1448,22 @@ struct xetter_cpp_function<
14481448 template <typename PM>
14491449 static cpp_function readonly (PM pm, const handle &hdl) {
14501450 return cpp_function (
1451- [pm](const std::shared_ptr<T> &c_sp) -> std::shared_ptr<D> {
1452- // Emulating PyCLIF approach:
1453- // https://github.com/google/clif/blob/c371a6d4b28d25d53a16e6d2a6d97305fb1be25a/clif/python/instance.h#L233
1454- return std::shared_ptr<D>(c_sp, &(c_sp.get ()->*pm));
1451+ [pm](const std::shared_ptr<T> &c_sp)
1452+ -> std::shared_ptr<typename std::add_const<D>::type> {
1453+ return std::shared_ptr<typename std::add_const<D>::type>(c_sp, &(c_sp.get ()->*pm));
14551454 },
14561455 is_method (hdl));
14571456 }
14581457
14591458 template <typename PM>
14601459 static cpp_function read (PM pm, const handle &hdl) {
1461- return readonly (pm, hdl);
1460+ return cpp_function (
1461+ [pm](const std::shared_ptr<T> &c_sp) -> std::shared_ptr<D> {
1462+ // Emulating PyCLIF approach:
1463+ // https://github.com/google/clif/blob/c371a6d4b28d25d53a16e6d2a6d97305fb1be25a/clif/python/instance.h#L233
1464+ return std::shared_ptr<D>(c_sp, &(c_sp.get ()->*pm));
1465+ },
1466+ is_method (hdl));
14621467 }
14631468
14641469 template <typename PM>
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ TEST_SUBMODULE(class_sh_property, m) {
6262
6363 py::classh<Outer>(m, " Outer" ) //
6464 .def (py::init<>()) //
65- // .def_readonly("m_valu_readonly", &Outer::m_valu) //
65+ .def_readonly (" m_valu_readonly" , &Outer::m_valu) //
6666 .def_readwrite (" m_valu" , &Outer::m_valu) //
6767 .def_property ( //
6868 " m_mptr_property" ,
You can’t perform that action at this time.
0 commit comments