@@ -1174,6 +1174,14 @@ class class_ : public detail::generic_type {
1174
1174
return *this ;
1175
1175
}
1176
1176
1177
+ template <typename C, typename D, typename ... Extra>
1178
+ class_ &def_writeonly (const char *name, D C::*pm, const Extra& ...extra) {
1179
+ static_assert (std::is_base_of<C, type>::value, " def_writeonly() requires a class member (or base class member)" );
1180
+ cpp_function fset ([pm](type &c, const D &value) { c.*pm = value; }, is_method (*this ));
1181
+ def_property_writeonly (name, fset, extra...);
1182
+ return *this ;
1183
+ }
1184
+
1177
1185
template <typename D, typename ... Extra>
1178
1186
class_ &def_readwrite_static (const char *name, D *pm, const Extra& ...extra) {
1179
1187
cpp_function fget ([pm](object) -> const D &{ return *pm; }, scope (*this )),
@@ -1189,31 +1197,58 @@ class class_ : public detail::generic_type {
1189
1197
return *this ;
1190
1198
}
1191
1199
1200
+ template <typename D, typename ... Extra>
1201
+ class_ &def_writeonly_static (const char *name, D *pm, const Extra& ...extra) {
1202
+ cpp_function fset ([pm](object, const D &value) { *pm = value; }, scope (*this ));
1203
+ def_property_writeonly_static (name, fset, extra...);
1204
+ return *this ;
1205
+ }
1206
+
1192
1207
// / Uses return_value_policy::reference_internal by default
1193
1208
template <typename Getter, typename ... Extra>
1194
1209
class_ &def_property_readonly (const char *name, const Getter &fget, const Extra& ...extra) {
1195
1210
return def_property_readonly (name, cpp_function (method_adaptor<type>(fget)),
1196
1211
return_value_policy::reference_internal, extra...);
1197
1212
}
1198
1213
1214
+ template <typename Setter, typename ... Extra>
1215
+ class_ &def_property_writeonly (const char *name, const Setter &fset, const Extra& ...extra) {
1216
+ return def_property_writeonly (name, cpp_function (method_adaptor<type>(fset)),extra...);
1217
+ }
1218
+
1199
1219
// / Uses cpp_function's return_value_policy by default
1200
1220
template <typename ... Extra>
1201
1221
class_ &def_property_readonly (const char *name, const cpp_function &fget, const Extra& ...extra) {
1202
1222
return def_property (name, fget, cpp_function (), extra...);
1203
1223
}
1204
1224
1225
+ template <typename ... Extra>
1226
+ class_ &def_property_writeonly (const char *name, const cpp_function &fset, const Extra& ...extra) {
1227
+ return def_property (name, cpp_function (), fset, extra...);
1228
+ }
1229
+
1205
1230
// / Uses return_value_policy::reference by default
1206
1231
template <typename Getter, typename ... Extra>
1207
1232
class_ &def_property_readonly_static (const char *name, const Getter &fget, const Extra& ...extra) {
1208
1233
return def_property_readonly_static (name, cpp_function (fget), return_value_policy::reference, extra...);
1209
1234
}
1210
1235
1236
+ template <typename Setter, typename ... Extra>
1237
+ class_ &def_property_writeonly_static (const char *name, const Setter &fset, const Extra& ...extra) {
1238
+ return def_property_writeonly_static (name, cpp_function (fset), extra...);
1239
+ }
1240
+
1211
1241
// / Uses cpp_function's return_value_policy by default
1212
1242
template <typename ... Extra>
1213
1243
class_ &def_property_readonly_static (const char *name, const cpp_function &fget, const Extra& ...extra) {
1214
1244
return def_property_static (name, fget, cpp_function (), extra...);
1215
1245
}
1216
1246
1247
+ template <typename ... Extra>
1248
+ class_ &def_property_writeonly_static (const char *name, const cpp_function &fset, const Extra& ...extra) {
1249
+ return def_property_static (name, cpp_function (), fset, extra...);
1250
+ }
1251
+
1217
1252
// / Uses return_value_policy::reference_internal by default
1218
1253
template <typename Getter, typename Setter, typename ... Extra>
1219
1254
class_ &def_property (const char *name, const Getter &fget, const Setter &fset, const Extra& ...extra) {
0 commit comments