-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Edited draft through relocation section
- Loading branch information
1 parent
62d2a4f
commit b7f809d
Showing
4 changed files
with
74 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#feature on safety | ||
#include <std2.h> | ||
|
||
int main() safe { | ||
// Objects start off uninitialized. A use of an uninitialized | ||
// object is ill-formed. | ||
std2::string s; | ||
|
||
// Require explicit initialization. | ||
s = std2::string("Hello "); | ||
|
||
// Require explicit mutation. | ||
mut s.append("World"); | ||
|
||
// Require explicit relocation. | ||
std2::string s2 = rel s; // Now s is uninitialized. | ||
|
||
// Require explicit non-trivial copy. | ||
std2::string s3 = cpy s2; | ||
|
||
// `Hello World`. | ||
println(s3); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters