Provide SWIGTYPE MOVE typemaps in swigmove.i
For implementing full move semantics when passing parameters by value. Based on SWIGTYPE && and std::unique_ptr typemaps which implement move semantics. Added for all languages, but untested for: Go, Ocaml, R, Scilab (and unlikely to be fully functional for same reasons as for std::unique_ptr support). Issue #999
This commit is contained in:
parent
de65875955
commit
dad7c93ca0
41 changed files with 909 additions and 19 deletions
35
Examples/test-suite/tcl/cpp11_move_typemaps_runme.tcl
Normal file
35
Examples/test-suite/tcl/cpp11_move_typemaps_runme.tcl
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
if [ catch { load ./cpp11_move_typemaps[info sharedlibextension] cpp11_move_typemaps} err_msg ] {
|
||||
puts stderr "Could not load shared object:\n$err_msg"
|
||||
}
|
||||
|
||||
Counter_reset_counts
|
||||
MoveOnly mo 111
|
||||
Counter_check_counts 1 0 0 0 0 0
|
||||
MoveOnly_take mo
|
||||
Counter_check_counts 1 0 0 1 0 2
|
||||
mo -delete
|
||||
Counter_check_counts 1 0 0 1 0 2
|
||||
|
||||
Counter_reset_counts
|
||||
MovableCopyable mo 111
|
||||
Counter_check_counts 1 0 0 0 0 0
|
||||
MovableCopyable_take mo
|
||||
Counter_check_counts 1 0 0 1 0 2
|
||||
mo -delete
|
||||
Counter_check_counts 1 0 0 1 0 2
|
||||
|
||||
MoveOnly mo 222
|
||||
MoveOnly_take mo
|
||||
set exception_thrown 0
|
||||
if [ catch {
|
||||
MoveOnly_take mo
|
||||
} e ] {
|
||||
if {[string first "cannot release ownership as memory is not owned" $e] == -1} {
|
||||
error "incorrect exception message: $e"
|
||||
}
|
||||
set exception_thrown 1
|
||||
}
|
||||
if {!$exception_thrown} {
|
||||
error "Should have thrown 'Cannot release ownership as memory is not owned' error"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue