Last change
on this file since 62b5940 was
62b5940,
checked in by Michael Brooks <mlbrooks@…>, 5 days ago
|
Flesh out the string_sharectx demo
|
-
Property mode set to
100644
|
File size:
1018 bytes
|
Rev | Line | |
---|
[bbf6a180] | 1 | #include <string.hfa> |
---|
| 2 | #include <string_sharectx.hfa> |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | |
---|
[62b5940] | 10 | void a( string & sm ) { |
---|
| 11 | string sm_a = sm; // share |
---|
| 12 | } |
---|
| 13 | void b( string & sm ) { |
---|
| 14 | string sm_b = sm; // share |
---|
| 15 | } |
---|
| 16 | void c( string & sm, string & sh1 ) { |
---|
| 17 | string sm_c = sm; // copy |
---|
| 18 | string sh1_c = sh1; // copy |
---|
| 19 | } |
---|
| 20 | void d( string & sm, string & sh1 ) { |
---|
| 21 | string sm_d = sm; // copy |
---|
| 22 | string sh1_d = sh1; // copy |
---|
| 23 | } |
---|
| 24 | void e( string & sm, string & sh1, string & sh2 ) { |
---|
| 25 | string sm_e = sm; // copy |
---|
| 26 | string sh1_e = sh1; // copy |
---|
| 27 | string sh2_e = sh2; // share |
---|
| 28 | } |
---|
| 29 | void f( string & sm, string & sh1 ) { |
---|
| 30 | string sm_f = sm; // copy |
---|
| 31 | string sh1_f = sh1; // copy |
---|
| 32 | } |
---|
| 33 | void g( string & sm ) { |
---|
| 34 | string sm_g = sm; // share |
---|
| 35 | } |
---|
| 36 | void helper2( string & sm, string & sh1 ) { |
---|
| 37 | d( sm, sh1 ); |
---|
| 38 | string_sharectx ctx_on = {NEW_SHARING}; |
---|
| 39 | string sh2 = "sh2"; |
---|
| 40 | e( sm, sh1, sh2 ); |
---|
| 41 | } |
---|
| 42 | void helper1( string & sm ) { |
---|
| 43 | b( sm ); |
---|
| 44 | string_sharectx ctx_off = {NO_SHARING}; |
---|
| 45 | string sh1 = "sh1"; |
---|
| 46 | c( sm, sh1 ); |
---|
| 47 | helper2( sm, sh1 ); |
---|
| 48 | f( sm, sh1 ); |
---|
[bbf6a180] | 49 | } |
---|
| 50 | int main() { |
---|
[62b5940] | 51 | string sm = "sm"; |
---|
| 52 | a( sm ); |
---|
| 53 | helper1( sm ); |
---|
| 54 | g( sm ); |
---|
[bbf6a180] | 55 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.