From e4c1dadb85e08d88fbc706e49a5d2b18b39fe0ed Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Sun, 3 Jan 2021 10:50:41 +0100 Subject: Force template argument *clone* to be specified when *del* is specified for containers. Can be *c_no_clone* if clonable is not required. --- examples/share_ptr2.c | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 examples/share_ptr2.c (limited to 'examples/share_ptr2.c') diff --git a/examples/share_ptr2.c b/examples/share_ptr2.c deleted file mode 100644 index 34abcd74..00000000 --- a/examples/share_ptr2.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include -#include - -typedef struct { cstr_t name, last; } Person; - -Person* Person_from(Person* p, cstr_t name, cstr_t last) { - p->name = name, p->last = last; - return p; -} -void Person_del(Person* p) { - c_del(cstr, &p->name, &p->last); -} - -using_csptr(ps, Person, c_no_compare, Person_del); -using_cmap(ps, int, csptr_ps, csptr_ps_del); - - -int main() { - cmap_ps map = cmap_ps_init(); - c_forrange (i, 20) { - c_try_emplace(&map, cmap_ps, (i * 7) % 10, - csptr_ps_from(Person_from(c_new(Person), cstr_from_fmt("Name %d", (i * 7) % 10), - cstr_from_fmt("Last %d", (i * 9) % 10)))); - } - c_foreach (i, cmap_ps, map) - printf(" %d: %s\n", i.ref->first, i.ref->second.get->name.str); - cmap_ps_del(&map); -} \ No newline at end of file -- cgit v1.2.3