summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-12-12 22:57:57 +0100
committerTyge Løvset <[email protected]>2021-12-12 22:57:57 +0100
commit657cdc6af3de15c5027858b703f1003841a5bbd0 (patch)
treee8e6d5173f99629fb8e2bcd3b79cefe4178e9d42 /examples
parent1bd66bde7a558cf2195a1241f4c5bd17fa3d856e (diff)
downloadSTC-modified-657cdc6af3de15c5027858b703f1003841a5bbd0.tar.gz
STC-modified-657cdc6af3de15c5027858b703f1003841a5bbd0.zip
Fixed example bug.
Diffstat (limited to 'examples')
-rw-r--r--examples/ptr_elems.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/examples/ptr_elems.c b/examples/ptr_elems.c
index b16fd97a..47cdc7d1 100644
--- a/examples/ptr_elems.c
+++ b/examples/ptr_elems.c
@@ -13,16 +13,15 @@ struct { double x, y; } typedef Point;
#define i_tag pnt
#include <stc/cset.h>
-/*
// Map of int64 pointers: For fun, define valraw as int64_t for easy emplace call!
+typedef int64_t inttype;
#define i_key_str
-#define i_valraw int64_t
-#define i_val i_valraw*
+#define i_valraw inttype
+#define i_val inttype*
#define i_valdel(x) c_free(*(x))
-#define i_valfrom(raw) c_new(i_valraw, raw)
+#define i_valfrom(raw) c_new(inttype, raw)
#define i_valto(x) **(x)
#include <stc/cmap.h>
-*/
int main()
{
@@ -47,12 +46,11 @@ int main()
puts("");
}
-/* // Need to check why this fails.
c_auto (cmap_str, map)
{
printf("\nMap with pointer elements:\n");
- cmap_str_insert(&map, cstr_lit("testing"), c_new(int, 999));
- cmap_str_insert(&map, cstr_lit("done"), c_new(int, 111));
+ cmap_str_insert(&map, cstr_lit("testing"), c_new(inttype, 999));
+ cmap_str_insert(&map, cstr_lit("done"), c_new(inttype, 111));
// Emplace: implicit key, val construction using i_keyfrom/i_valfrom:
cmap_str_emplace(&map, "hello", 200);
@@ -61,5 +59,4 @@ int main()
c_forpair (name, number, cmap_str, map)
printf("%s: %zd\n", _.name.str, *_.number);
}
-*/
}