diff options
| author | Tyge Løvset <[email protected]> | 2023-07-18 02:36:04 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-07-18 02:36:04 +0200 |
| commit | da70303c149b37dbf442e41038a00836132562ee (patch) | |
| tree | 06d795c66d6759e06de5f2d166215b461ac40d1d /misc/examples/new_sptr.c | |
| parent | 071b41c0fe95cb3f9a72bbe0417d856e7989ca08 (diff) | |
| parent | 23eeedb3fc298602732f394adba6a43c876ca7d8 (diff) | |
| download | STC-modified-da70303c149b37dbf442e41038a00836132562ee.tar.gz STC-modified-da70303c149b37dbf442e41038a00836132562ee.zip | |
Merge branch 'dev43' into master
Diffstat (limited to 'misc/examples/new_sptr.c')
| -rw-r--r-- | misc/examples/new_sptr.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/misc/examples/new_sptr.c b/misc/examples/new_sptr.c index 1b72e4f5..7fef5d1f 100644 --- a/misc/examples/new_sptr.c +++ b/misc/examples/new_sptr.c @@ -1,3 +1,4 @@ +#define i_implement #include <stc/cstr.h> typedef struct { cstr name, last; } Person; @@ -8,28 +9,27 @@ int Person_cmp(const Person* a, const Person* b); uint64_t Person_hash(const Person* p); #define i_type PersonArc -#define i_valclass Person // "class" ensure Person_drop will be called -#define i_cmp Person_cmp // enable carc object comparisons (not ptr to obj) -#define i_hash Person_hash // enable carc object hash (not ptr to obj) +#define i_keyclass Person // "class" assume _clone, _drop, _cmp, _hash is defined. #include <stc/carc.h> #define i_type IPtr -#define i_val int -#define i_valdrop(x) printf("drop: %d\n", *x) -#define i_no_clone +#define i_key int +#define i_keydrop(x) printf("drop: %d\n", *x) +#define i_native_cmp #include <stc/carc.h> #define i_type IPStack -#define i_valboxed IPtr +#define i_keyboxed IPtr #include <stc/cstack.h> #define i_type PASet -#define i_valboxed PersonArc +#define i_keyboxed PersonArc #include <stc/cset.h> Person Person_make(const char* name, const char* last) { - return (Person){.name = cstr_from(name), .last = cstr_from(last)}; + Person p = {.name = cstr_from(name), .last = cstr_from(last)}; + return p; } int Person_cmp(const Person* a, const Person* b) { |
