From: Mikko Rasa Date: Mon, 19 Dec 2022 14:52:50 +0000 (+0200) Subject: Use braced initializer lists for map insertions X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=1ec533a7777be4dce9c8b6bbb1cbc32d38098ae4;p=builder.git Use braced initializer lists for map insertions --- diff --git a/source/builder.cpp b/source/builder.cpp index 2159266..a49624d 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -324,7 +324,7 @@ void Builder::Loader::build_type(const string &n) { BuildType btype(n); load_sub(btype); - auto i = obj.build_types.insert(BuildTypeMap::value_type(n, btype)).first; + auto i = obj.build_types.insert({ n, btype }).first; if(!obj.build_type) obj.build_type = &i->second; } diff --git a/source/buildercli.cpp b/source/buildercli.cpp index bf53c29..94b8f52 100644 --- a/source/buildercli.cpp +++ b/source/buildercli.cpp @@ -126,7 +126,7 @@ BuilderCLI::BuilderCLI(int argc, char **argv): string::size_type equal = i->find('='); if(equal!=string::npos) { - cmdline_options.insert(Config::InputOptions::value_type(i->substr(0, equal), i->substr(equal+1))); + cmdline_options.insert({ i->substr(0, equal), i->substr(equal+1) }); cmdline_targets.erase(i++); } else diff --git a/source/buildgraph.cpp b/source/buildgraph.cpp index 46c0c48..070f934 100644 --- a/source/buildgraph.cpp +++ b/source/buildgraph.cpp @@ -33,7 +33,7 @@ Target *BuildGraph::get_target(const string &n) const void BuildGraph::add_target(Target *t) { - targets.insert(TargetMap::value_type(t->get_name(), t)); + targets.insert({ t->get_name(), t }); } void BuildGraph::add_primary_target(Target &t) diff --git a/source/cache.cpp b/source/cache.cpp index 61a4cb4..57b16d1 100644 --- a/source/cache.cpp +++ b/source/cache.cpp @@ -75,7 +75,7 @@ void Cache::append_value(const Target *tgt, const string &k, const string &v) Key key(tgt->get_name(), k); auto i = data.find(key); if(i==data.end()) - i = data.insert(DataMap::value_type(key, ValueList())).first; + i = data.insert({ key, ValueList() }).first; i->second.push_back(v); changed = true; package.get_builder().get_logger().log("cache", format("Updated key %s %s+ %s", tgt->get_name(), k, v)); diff --git a/source/config.cpp b/source/config.cpp index a0603cf..67f932f 100644 --- a/source/config.cpp +++ b/source/config.cpp @@ -23,7 +23,7 @@ const Config::Option &Config::add_option(const Feature &f) if(i!=pending_options.end()) opt.value = i->second; - return options.insert(OptionMap::value_type(opt.name, opt)).first->second; + return options.insert({ opt.name, opt }).first->second; } bool Config::set_option(const string &opt, const string &val) diff --git a/source/packagemanager.cpp b/source/packagemanager.cpp index 54cd550..af672d9 100644 --- a/source/packagemanager.cpp +++ b/source/packagemanager.cpp @@ -59,7 +59,7 @@ void PackageManager::add_package(Package *pkg) if(packages.empty()) main_pkg = pkg; - packages.insert(PackageMap::value_type(pkg->get_name(), pkg)); + packages.insert({ pkg->get_name(), pkg }); } Package *PackageManager::get_package(const string &name) const @@ -114,7 +114,7 @@ Package *PackageManager::find_package(const string &name) flags_str = run_pkgconfig(name, "staticflags"); BinaryPackage::Flags static_flags = split(flags_str); Package *pkg = BinaryPackage::from_flags(builder, name, flags, static_flags); - packages.insert(PackageMap::value_type(name, pkg)); + packages.insert({ name, pkg }); return pkg; } catch(...) diff --git a/source/virtualfilesystem.cpp b/source/virtualfilesystem.cpp index 0c3ee36..7855e04 100644 --- a/source/virtualfilesystem.cpp +++ b/source/virtualfilesystem.cpp @@ -30,7 +30,7 @@ FileTarget *VirtualFileSystem::get_target(const FS::Path &p) const void VirtualFileSystem::register_path(const FS::Path &path, FileTarget *t) { - targets.insert(TargetMap::value_type(path.str(), t)); + targets.insert({ path, t }); nonexistent.erase(path); builder.get_logger().log("vfs", format("Path %s registered to %s", path, t->get_name())); }