Repository navigation
Commit cc5f8a2
authored
Add Swappable trait (#689)
Depends on #688
Add the swappable trait and delete the cpp_swap macro. `swap_by_move` is
a new libcc2rs function with the necessary traits:
```rs
pub fn swap_by_move<T>(this: &Ptr<T>, other: Ptr<T>)
where
T: MoveConstructible + MoveAssignable + Destructible + ZeroInitialization
```
The standard explicitely requires MoveConstructible and MoveAssignable,
and implicitly requires Destructible. ZeroInitialization is an artefact
of refcount which needs storage to build objects into it.
ZeroInitialization has no side-effects so it's ok to have the trait
attached.
---
I also had to change Destructible to be implemented by records with
empty destruction, otherwise records with empty Destructible could not
call swap_by_move.1 parent de0e4d7 commit cc5f8a2
630 files changed
Lines changed: 16977 additions & 6106 deletions
File tree
- cpp2rust
- converter
- models
- libcc2rs-macros/src
- libcc2rs/src
- rules
- algorithm
- array
- dirent
- ifaddrs
- ip
- map
- netdb
- poll
- pwd
- select
- socket
- stat
- termios
- time
- unique_ptr
- vector
- tests
- multi-file
- cross_tu_tag_collision/out
- refcount
- unsafe
- defaulted_move_cross_tu/out
- refcount
- unsafe
- friend_operator/out
- refcount
- unsafe
- opaque_forward_decl/out
- refcount
- unsafe
- out_of_line_methods_cross_tu/out
- refcount
- unsafe
- template_method_late_instantiation/out
- refcount
- unsafe
- std
- basic
- basic.def.odr
- p14-class-in-two-files/out
- refcount
- unsafe
- p15-class-template-static-member/out
- refcount
- unsafe
- p15-function-template/out
- refcount
- unsafe
- p15-inline-function/out
- refcount
- unsafe
- p15-inline-variable/out
- refcount
- unsafe
- p16-default-argument-lambda-in-class/out
- refcount
- unsafe
- p16-lambda-in-inline-function/out
- refcount
- unsafe
- basic.link/out
- refcount
- unsafe
- basic.scope/out
- refcount
- unsafe
- basic.start/out
- refcount
- unsafe
- basic.types/out
- refcount
- unsafe
- out
- refcount
- unsafe
- class
- class.init/out
- refcount
- unsafe
- class.mem
- class.conv/out
- refcount
- unsafe
- class.ctor/out
- refcount
- unsafe
- out
- refcount
- unsafe
- dcl.dcl/dcl.decl
- dcl.init/out
- refcount
- unsafe
- dcl.meaning/out
- refcount
- unsafe
- expr
- conv/out
- refcount
- unsafe
- expr.compound
- expr.post/out
- refcount
- unsafe
- expr.unary/out
- refcount
- unsafe
- out
- refcount
- unsafe
- expr.prim/out
- refcount
- unsafe
- library/requirements/utility.requirements/allocator.requirements/out
- refcount
- unsafe
- stmt.stmt
- stmt.iter/out
- refcount
- unsafe
- stmt.select/out
- refcount
- unsafe
- temp
- out
- refcount
- unsafe
- temp.spec/out
- refcount
- unsafe
- utilities/utility/out
- refcount
- unsafe
- ub/out
- refcount
- unsafe
- unit/out
- refcount
- unsafe
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| 112 | + | |
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| |||
358 | 360 | | |
359 | 361 | | |
360 | 362 | | |
361 | | - | |
362 | | - | |
| 363 | + | |
363 | 364 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
| 365 | + | |
| 366 | + | |
372 | 367 | | |
373 | 368 | | |
374 | 369 | | |
| |||
892 | 887 | | |
893 | 888 | | |
894 | 889 | | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
895 | 896 | | |
896 | 897 | | |
897 | 898 | | |
| |||
1271 | 1272 | | |
1272 | 1273 | | |
1273 | 1274 | | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
1274 | 1280 | | |
1275 | 1281 | | |
1276 | 1282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
602 | 602 | | |
603 | 603 | | |
604 | 604 | | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
605 | 657 | | |
606 | 658 | | |
607 | 659 | | |
| |||
731 | 783 | | |
732 | 784 | | |
733 | 785 | | |
734 | | - | |
| 786 | + | |
735 | 787 | | |
736 | 788 | | |
737 | 789 | | |
| |||
743 | 795 | | |
744 | 796 | | |
745 | 797 | | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
746 | 807 | | |
747 | | - | |
| 808 | + | |
748 | 809 | | |
749 | 810 | | |
750 | | - | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
751 | 814 | | |
752 | 815 | | |
753 | 816 | | |
| |||
771 | 834 | | |
772 | 835 | | |
773 | 836 | | |
774 | | - | |
| 837 | + | |
775 | 838 | | |
776 | 839 | | |
777 | 840 | | |
| |||
918 | 981 | | |
919 | 982 | | |
920 | 983 | | |
921 | | - | |
922 | | - | |
| 984 | + | |
| 985 | + | |
923 | 986 | | |
924 | 987 | | |
925 | 988 | | |
| |||
1756 | 1819 | | |
1757 | 1820 | | |
1758 | 1821 | | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
1759 | 1839 | | |
1760 | 1840 | | |
1761 | 1841 | | |
| |||
1862 | 1942 | | |
1863 | 1943 | | |
1864 | 1944 | | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
1865 | 1952 | | |
1866 | 1953 | | |
1867 | 1954 | | |
| |||
1906 | 1993 | | |
1907 | 1994 | | |
1908 | 1995 | | |
1909 | | - | |
1910 | | - | |
| 1996 | + | |
| 1997 | + | |
1911 | 1998 | | |
1912 | 1999 | | |
1913 | 2000 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
108 | 146 | | |
109 | 147 | | |
110 | 148 | | |
| |||
288 | 326 | | |
289 | 327 | | |
290 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
291 | 334 | | |
292 | 335 | | |
293 | 336 | | |
| |||
0 commit comments