Define move ctor and assignment operator for C++ wrappers
This can be done naturally and there doesn't seem to be any reason not to do it.
This commit is contained in:
parent
79e9d43c1b
commit
3f3438093d
1 changed files with 22 additions and 0 deletions
|
|
@ -571,6 +571,28 @@ public:
|
||||||
NIL
|
NIL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// OTOH we may always provide move ctor and assignment, as we can always implement them trivially ourselves.
|
||||||
|
if (first_base_) {
|
||||||
|
Printv(cxx_wrappers_.f_decls,
|
||||||
|
cindent, classname, "(", classname, "&& obj) = default;\n",
|
||||||
|
cindent, classname, "& operator=(", classname, "&& obj) = default;\n",
|
||||||
|
NIL
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Printv(cxx_wrappers_.f_decls,
|
||||||
|
cindent, classname, "(", classname, "&& obj) : "
|
||||||
|
"swig_self_{obj.swig_self_}, swig_owns_self_{obj.swig_owns_self_} { "
|
||||||
|
"obj.swig_owns_self_ = false; "
|
||||||
|
"}\n",
|
||||||
|
cindent, classname, "& operator=(", classname, "&& obj) { "
|
||||||
|
"swig_self_ = obj.swig_self_; swig_owns_self_ = obj.swig_owns_self_; "
|
||||||
|
"obj.swig_owns_self_ = false; "
|
||||||
|
"return *this; "
|
||||||
|
"}\n",
|
||||||
|
NIL
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// We also need a swig_self() method for accessing the C object pointer.
|
// We also need a swig_self() method for accessing the C object pointer.
|
||||||
Printv(cxx_wrappers_.f_decls,
|
Printv(cxx_wrappers_.f_decls,
|
||||||
cindent, c_class_ptr.get(), " swig_self() const noexcept ",
|
cindent, c_class_ptr.get(), " swig_self() const noexcept ",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue