Always pass wrapper objects by const reference in C++ wrappers
Passing them by value doesn't seem to have any advantages, as the copy will be made internally anyhow if the original function took them by value and doing an extra one doesn't seem necessary, but does have a big drawback of not compiling if the class doesn't define a copy ctor.
This commit is contained in:
parent
3f3438093d
commit
adb96f8b7a
1 changed files with 4 additions and 0 deletions
|
|
@ -819,6 +819,10 @@ private:
|
|||
}
|
||||
|
||||
if (ptype_desc) {
|
||||
// It doesn't seem like it can ever be useful to pass an object by value to a wrapper function and it can fail if it doesn't have a copy ctor (see
|
||||
// code related to has_copy_ctor_ in our dtor above), so always pass it by const reference instead.
|
||||
Append(typestr, " const&");
|
||||
|
||||
Append(ptype_desc->wrap_end(), ".swig_self()");
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue