From 8dd8368bca262dbab39741fbbb61c16478772e4e Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Thu, 10 Sep 2020 20:48:44 +0200 Subject: 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. --- examples/mapmap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'examples/mapmap.c') 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) -- cgit v1.2.3