summaryrefslogtreecommitdiffhomepage
path: root/docs/cbox_api.md
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-02-08 16:16:49 +0100
committerTyge Løvset <[email protected]>2023-02-08 17:18:24 +0100
commitc4441f5fc665194fbd7a894a67a64a08c3beac42 (patch)
tree82f231b6e8fcb75625166f98aa785baaa265a3d6 /docs/cbox_api.md
parent673dd5319a488d4b702b94dd9aeda4e497ae4fbc (diff)
downloadSTC-modified-c4441f5fc665194fbd7a894a67a64a08c3beac42.tar.gz
STC-modified-c4441f5fc665194fbd7a894a67a64a08c3beac42.zip
Changed to use lowercase flow-control macros in examples (uppercase will still be supported). Improved many examples to use c_make() to init containers.
Diffstat (limited to 'docs/cbox_api.md')
-rw-r--r--docs/cbox_api.md15
1 files changed, 7 insertions, 8 deletions
diff --git a/docs/cbox_api.md b/docs/cbox_api.md
index 4430b9f8..eff0fbc1 100644
--- a/docs/cbox_api.md
+++ b/docs/cbox_api.md
@@ -92,18 +92,17 @@ void int_drop(int* x) {
int main()
{
- c_AUTO (IVec, vec) // declare and init vec, call drop at scope exit
- c_AUTO (ISet, set) // similar
+ c_auto (IVec, vec) // declare and init vec, call drop at scope exit
+ c_auto (ISet, set) // similar
{
- c_FORLIST (i, int, {2021, 2012, 2022, 2015})
- IVec_emplace(&vec, *i.ref); // same as: IVec_push(&vec, IBox_from(*i.ref));
+ vec = c_make(Vec, {2021, 2012, 2022, 2015});
printf("vec:");
- c_FOREACH (i, IVec, vec)
+ c_foreach (i, IVec, vec)
printf(" %d", *i.ref->get);
// add odd numbers from vec to set
- c_FOREACH (i, IVec, vec)
+ c_foreach (i, IVec, vec)
if (*i.ref->get & 1)
ISet_insert(&set, IBox_clone(*i.ref));
@@ -112,11 +111,11 @@ int main()
IVec_pop(&vec);
printf("\nvec:");
- c_FOREACH (i, IVec, vec)
+ c_foreach (i, IVec, vec)
printf(" %d", *i.ref->get);
printf("\nset:");
- c_FOREACH (i, ISet, set)
+ c_foreach (i, ISet, set)
printf(" %d", *i.ref->get);
}
}