@@ -201,22 +201,22 @@ void construct(value_and_holder &v_h, Alias<Class> &&result, bool) {
201
201
template <typename ... Args>
202
202
struct constructor {
203
203
template <typename Class, typename ... Extra, enable_if_t <!Class::has_alias, int > = 0 >
204
- static void execute (Class &cl, const Extra &...extra) {
204
+ static void execute (Class &cl, Extra & &...extra) {
205
205
cl.def (
206
206
" __init__" ,
207
207
[](value_and_holder &v_h, Args... args) {
208
208
v_h.value_ptr () = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
209
209
},
210
210
is_new_style_constructor (),
211
- extra...);
211
+ std::forward<Extra>( extra) ...);
212
212
}
213
213
214
214
template <
215
215
typename Class,
216
216
typename ... Extra,
217
217
enable_if_t <Class::has_alias && std::is_constructible<Cpp<Class>, Args...>::value, int >
218
218
= 0 >
219
- static void execute (Class &cl, const Extra &...extra) {
219
+ static void execute (Class &cl, Extra & &...extra) {
220
220
cl.def (
221
221
" __init__" ,
222
222
[](value_and_holder &v_h, Args... args) {
@@ -229,23 +229,23 @@ struct constructor {
229
229
}
230
230
},
231
231
is_new_style_constructor (),
232
- extra...);
232
+ std::forward<Extra>( extra) ...);
233
233
}
234
234
235
235
template <
236
236
typename Class,
237
237
typename ... Extra,
238
238
enable_if_t <Class::has_alias && !std::is_constructible<Cpp<Class>, Args...>::value, int >
239
239
= 0 >
240
- static void execute (Class &cl, const Extra &...extra) {
240
+ static void execute (Class &cl, Extra & &...extra) {
241
241
cl.def (
242
242
" __init__" ,
243
243
[](value_and_holder &v_h, Args... args) {
244
244
v_h.value_ptr ()
245
245
= construct_or_initialize<Alias<Class>>(std::forward<Args>(args)...);
246
246
},
247
247
is_new_style_constructor (),
248
- extra...);
248
+ std::forward<Extra>( extra) ...);
249
249
}
250
250
};
251
251
@@ -257,15 +257,15 @@ struct alias_constructor {
257
257
typename ... Extra,
258
258
enable_if_t <Class::has_alias && std::is_constructible<Alias<Class>, Args...>::value, int >
259
259
= 0 >
260
- static void execute (Class &cl, const Extra &...extra) {
260
+ static void execute (Class &cl, Extra & &...extra) {
261
261
cl.def (
262
262
" __init__" ,
263
263
[](value_and_holder &v_h, Args... args) {
264
264
v_h.value_ptr ()
265
265
= construct_or_initialize<Alias<Class>>(std::forward<Args>(args)...);
266
266
},
267
267
is_new_style_constructor (),
268
- extra...);
268
+ std::forward<Extra>( extra) ...);
269
269
}
270
270
};
271
271
@@ -290,7 +290,7 @@ struct factory<Func, void_type (*)(), Return(Args...)> {
290
290
// inheriting from the C++ type) the returned value needs to either already be an alias
291
291
// instance, or the alias needs to be constructible from a `Class &&` argument.
292
292
template <typename Class, typename ... Extra>
293
- void execute (Class &cl, const Extra &...extra) && {
293
+ void execute (Class &cl, Extra & &...extra) && {
294
294
#if defined(PYBIND11_CPP14)
295
295
cl.def (
296
296
" __init__" ,
@@ -306,7 +306,7 @@ struct factory<Func, void_type (*)(), Return(Args...)> {
306
306
v_h, func (std::forward<Args>(args)...), Py_TYPE (v_h.inst ) != v_h.type ->type );
307
307
},
308
308
is_new_style_constructor (),
309
- extra...);
309
+ std::forward<Extra>( extra) ...);
310
310
}
311
311
};
312
312
@@ -334,7 +334,7 @@ struct factory<CFunc, AFunc, CReturn(CArgs...), AReturn(AArgs...)> {
334
334
// The class factory is called when the `self` type passed to `__init__` is the direct
335
335
// class (i.e. not inherited), the alias factory when `self` is a Python-side subtype.
336
336
template <typename Class, typename ... Extra>
337
- void execute (Class &cl, const Extra &...extra) && {
337
+ void execute (Class &cl, Extra & &...extra) && {
338
338
static_assert (Class::has_alias,
339
339
" The two-argument version of `py::init()` can "
340
340
" only be used if the class has an alias" );
@@ -359,7 +359,7 @@ struct factory<CFunc, AFunc, CReturn(CArgs...), AReturn(AArgs...)> {
359
359
}
360
360
},
361
361
is_new_style_constructor (),
362
- extra...);
362
+ std::forward<Extra>( extra) ...);
363
363
}
364
364
};
365
365
@@ -409,7 +409,7 @@ struct pickle_factory<Get, Set, RetState(Self), NewInstance(ArgState)> {
409
409
pickle_factory (Get get, Set set) : get(std::forward<Get>(get)), set(std::forward<Set>(set)) {}
410
410
411
411
template <typename Class, typename ... Extra>
412
- void execute (Class &cl, const Extra &...extra) && {
412
+ void execute (Class &cl, Extra & &...extra) && {
413
413
cl.def (" __getstate__" , std::move (get));
414
414
415
415
#if defined(PYBIND11_CPP14)
@@ -427,7 +427,7 @@ struct pickle_factory<Get, Set, RetState(Self), NewInstance(ArgState)> {
427
427
v_h, func (std::forward<ArgState>(state)), Py_TYPE (v_h.inst ) != v_h.type ->type );
428
428
},
429
429
is_new_style_constructor (),
430
- extra...);
430
+ std::forward<Extra>( extra) ...);
431
431
}
432
432
};
433
433
0 commit comments