Skip to content

Commit 0b821ba

Browse files
committed
Also using getter_cpp_function for def_property_readonly.
1 parent 6a78b7d commit 0b821ba

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

include/pybind11/pybind11.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,8 +1614,11 @@ class class_ : public detail::generic_type {
16141614
template <typename C, typename D, typename... Extra>
16151615
class_ &def_readonly(const char *name, const D C::*pm, const Extra& ...extra) {
16161616
static_assert(std::is_same<C, type>::value || std::is_base_of<C, type>::value, "def_readonly() requires a class member (or base class member)");
1617-
cpp_function fget([pm](const type &c) -> const D &{ return c.*pm; }, is_method(*this));
1618-
def_property_readonly(name, fget, return_value_policy::reference_internal, extra...);
1617+
def_property_readonly(
1618+
name,
1619+
getter_cpp_function<type, D>::make(pm, is_method(*this)),
1620+
return_value_policy::reference_internal,
1621+
extra...);
16191622
return *this;
16201623
}
16211624

0 commit comments

Comments
 (0)