summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/sidebyside.cpp
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-03-27 19:57:09 +0200
committerTyge Løvset <[email protected]>2023-03-27 19:57:09 +0200
commite35036deef4fc8f17cc9221e2e666dfdb832ba78 (patch)
treeb41e45015be7454ef3f82092b558da6b365d6a57 /misc/examples/sidebyside.cpp
parentede39bc98a758674485796174ea860515ec281e6 (diff)
downloadSTC-modified-e35036deef4fc8f17cc9221e2e666dfdb832ba78.tar.gz
STC-modified-e35036deef4fc8f17cc9221e2e666dfdb832ba78.zip
More RAII cleanup in examples. Also removed gauss1.c and new_deq.c
Diffstat (limited to 'misc/examples/sidebyside.cpp')
-rw-r--r--misc/examples/sidebyside.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/misc/examples/sidebyside.cpp b/misc/examples/sidebyside.cpp
index a817b5a5..a7c1008c 100644
--- a/misc/examples/sidebyside.cpp
+++ b/misc/examples/sidebyside.cpp
@@ -24,9 +24,8 @@ int main() {
std::cout << i.first << ", " << i.second << std::endl;
std::cout << std::endl;
}
-
- IIMap hist = {0};
- c_defer (IIMap_drop(&hist)) {
+ {
+ IIMap hist = {0};
IIMap_insert(&hist, 12, 100).ref->second += 1;
IIMap_insert(&hist, 13, 100).ref->second += 1;
IIMap_insert(&hist, 12, 100).ref->second += 1;
@@ -34,6 +33,7 @@ int main() {
c_foreach (i, IIMap, hist)
printf("%d, %d\n", i.ref->first, i.ref->second);
puts("");
+ IIMap_drop(&hist);
}
// ===================================================
{
@@ -44,15 +44,14 @@ int main() {
std::cout << i.first << ", " << i.second << std::endl;
std::cout << std::endl;
}
-
- SIMap food = {0};
- c_defer (SIMap_drop(&food))
{
+ SIMap food = {0};
c_forlist (i, SIMap_raw, {{"burger", 5}, {"pizza", 12}, {"steak", 15}})
SIMap_emplace(&food, i.ref->first, i.ref->second);
c_foreach (i, SIMap, food)
printf("%s, %d\n", cstr_str(&i.ref->first), i.ref->second);
puts("");
+ SIMap_drop(&food);
}
}