summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/sidebyside.cpp
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-03-26 00:27:45 +0100
committerTyge Løvset <[email protected]>2023-03-26 00:27:45 +0100
commiteb85069b669e754836b9d4587ba03d3af1a5e975 (patch)
tree45c9a0d3fe40c59a8b33ae8ecd2e7aa78bef6240 /misc/examples/sidebyside.cpp
parente8be14dfc894eeac859f0287d4d5b4f4745c0585 (diff)
downloadSTC-modified-eb85069b669e754836b9d4587ba03d3af1a5e975.tar.gz
STC-modified-eb85069b669e754836b9d4587ba03d3af1a5e975.zip
development branch for 4.2
Removed uses of c_auto and c_with in documentation examples and code examples. Still using c_defer a few places. Renamed c11/fmt.h to c11/print.h. Some additions in ccommon.h, e.g. c_const_cast(T, x). Improved docs.
Diffstat (limited to 'misc/examples/sidebyside.cpp')
-rw-r--r--misc/examples/sidebyside.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/misc/examples/sidebyside.cpp b/misc/examples/sidebyside.cpp
index 80c934a4..a817b5a5 100644
--- a/misc/examples/sidebyside.cpp
+++ b/misc/examples/sidebyside.cpp
@@ -25,8 +25,8 @@ int main() {
std::cout << std::endl;
}
- c_auto (IIMap, hist)
- {
+ IIMap hist = {0};
+ c_defer (IIMap_drop(&hist)) {
IIMap_insert(&hist, 12, 100).ref->second += 1;
IIMap_insert(&hist, 13, 100).ref->second += 1;
IIMap_insert(&hist, 12, 100).ref->second += 1;
@@ -45,10 +45,11 @@ int main() {
std::cout << std::endl;
}
- c_auto (SIMap, food)
+ SIMap food = {0};
+ c_defer (SIMap_drop(&food))
{
c_forlist (i, SIMap_raw, {{"burger", 5}, {"pizza", 12}, {"steak", 15}})
- SIMap_emplace(&food, c_PAIR(i.ref));
+ 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);