Skip to content

Commit c0756cc

Browse files
authored
fix: func_handle for rule of two (#3169)
* Fix func_handle for rule of two * Apply reviewer suggestion
1 parent f4f4632 commit c0756cc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/pybind11/functional.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ struct type_caster<std::function<Return(Args...)>> {
7070
struct func_handle {
7171
function f;
7272
func_handle(function &&f_) noexcept : f(std::move(f_)) {}
73-
func_handle(const func_handle& f_) {
73+
func_handle(const func_handle &f_) { operator=(f_); }
74+
func_handle &operator=(const func_handle &f_) {
7475
gil_scoped_acquire acq;
7576
f = f_.f;
77+
return *this;
7678
}
7779
~func_handle() {
7880
gil_scoped_acquire acq;

0 commit comments

Comments
 (0)