diff options
| author | Tyge Løvset <[email protected]> | 2022-01-11 21:01:21 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-01-11 21:01:21 +0100 |
| commit | f6f3580dec78782789fb9e90db28d0a68f0606a8 (patch) | |
| tree | 2b8b2a65f9f56a9599bf55355838c7729dffdf6a | |
| parent | d85a4e9e396688b6b5b29c0ffb07de7ce9013b74 (diff) | |
| download | STC-modified-f6f3580dec78782789fb9e90db28d0a68f0606a8.tar.gz STC-modified-f6f3580dec78782789fb9e90db28d0a68f0606a8.zip | |
Fixed c++ sidebyside example.
| -rw-r--r-- | examples/sidebyside.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/examples/sidebyside.cpp b/examples/sidebyside.cpp index d765fb91..89446b23 100644 --- a/examples/sidebyside.cpp +++ b/examples/sidebyside.cpp @@ -4,25 +4,29 @@ #define i_key_str
#define i_val int
+#define i_tag si
#include <stc/cmap.h>
#define i_key int
#define i_val int
+#define i_tag ii
#include <stc/csmap.h>
int main() {
{
std::map<std::string, int> food =
{{"burger", 5}, {"pizza", 12}, {"steak", 15}};
+
for (auto i: food)
std::cout << i.first << ", " << i.second << std::endl;
std::cout << std::endl;
}
- c_auto (cmap_str, food)
+ c_auto (cmap_si, food)
{
- c_apply(v, cmap_str_emplace(&food, c_pair(v)), cmap_str_raw,
+ c_apply(v, cmap_si_emplace(&food, c_pair(v)), cmap_si_raw,
{{"burger", 5}, {"pizza", 12}, {"steak", 15}});
- c_foreach (i, cmap_str, food)
+
+ c_foreach (i, cmap_si, food)
printf("%s, %d\n", i.ref->first.str, i.ref->second);
puts("");
}
@@ -32,16 +36,18 @@ int main() { ++ hist.emplace(12, 100).first->second;
++ hist.emplace(13, 100).first->second;
++ hist.emplace(12, 100).first->second;
+
for (auto i: hist)
std::cout << i.first << ", " << i.second << std::endl;
std::cout << std::endl;
}
- c_auto (csmap_int, hist)
+ c_auto (csmap_ii, hist)
{
- ++ csmap_int_emplace(&hist, 12, 100).ref->second;
- ++ csmap_int_emplace(&hist, 13, 100).ref->second;
- ++ csmap_int_emplace(&hist, 12, 100).ref->second;
- c_foreach (i, csmap_int, hist)
+ ++ csmap_ii_insert(&hist, 12, 100).ref->second;
+ ++ csmap_ii_insert(&hist, 13, 100).ref->second;
+ ++ csmap_ii_insert(&hist, 12, 100).ref->second;
+
+ c_foreach (i, csmap_ii, hist)
printf("%d, %d\n", i.ref->first, i.ref->second);
puts("");
}
|
