summaryrefslogtreecommitdiffhomepage
path: root/examples/mapmap.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-09-10 20:48:44 +0200
committerTyge Løvset <[email protected]>2020-09-10 20:48:44 +0200
commit8dd8368bca262dbab39741fbbb61c16478772e4e (patch)
treefa7b82f835a002f60a70d1b1b159fbb4a26f9bf5 /examples/mapmap.c
parent0b3e84cac29288af49bbabf2f880cd6319f9a1f3 (diff)
downloadSTC-modified-8dd8368bca262dbab39741fbbb61c16478772e4e.tar.gz
STC-modified-8dd8368bca262dbab39741fbbb61c16478772e4e.zip
Use cmap_emplace() rather than cmap_insert(). insert() is reduced to an alias of emplace() because it makes no sense using the std::unordered_map API.
Diffstat (limited to 'examples/mapmap.c')
-rw-r--r--examples/mapmap.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/mapmap.c b/examples/mapmap.c
index e1e78bba..f717a4bc 100644
--- a/examples/mapmap.c
+++ b/examples/mapmap.c
@@ -9,14 +9,14 @@ declare_cmap_strkey(cfg, cmap_str, cmap_str_destroy);
int main(void) {
cmap_cfg config = cmap_ini;
cmap_str init = cmap_ini;
- cmap_str_put(&cmap_cfg_insert(&config, "user", init).item->value, "name", "Joe");
- cmap_str_put(&cmap_cfg_insert(&config, "user", init).item->value, "groups", "proj1,proj3");
- cmap_str_put(&cmap_cfg_insert(&config, "group", init).item->value, "proj1", "Energy");
- cmap_str_put(&cmap_cfg_insert(&config, "group", init).item->value, "proj2", "Windy");
- cmap_str_put(&cmap_cfg_insert(&config, "group", init).item->value, "proj3", "Oil");
- cmap_str_put(&cmap_cfg_insert(&config, "admin", init).item->value, "employees", "2302");
+ cmap_str_put(&cmap_cfg_emplace(&config, "user", init).item->value, "name", "Joe");
+ cmap_str_put(&cmap_cfg_emplace(&config, "user", init).item->value, "groups", "proj1,proj3");
+ cmap_str_put(&cmap_cfg_emplace(&config, "group", init).item->value, "proj1", "Energy");
+ cmap_str_put(&cmap_cfg_emplace(&config, "group", init).item->value, "proj2", "Windy");
+ cmap_str_put(&cmap_cfg_emplace(&config, "group", init).item->value, "proj3", "Oil");
+ cmap_str_put(&cmap_cfg_emplace(&config, "admin", init).item->value, "employees", "2302");
- cmap_str_put(&cmap_cfg_insert(&config, "group", init).item->value, "proj2", "Wind"); // Update
+ cmap_str_put(&cmap_cfg_emplace(&config, "group", init).item->value, "proj2", "Wind"); // Update
c_foreach (i, cmap_cfg, config)
c_foreach (j, cmap_str, i.item->value)