Fix warning: possibly dangling reference to a temporary

This commit is contained in:
Tindy X committed 2023-10-11 19:51:28 +08:00
1 parent 705e94e53f
commit b281c9960b
1 file changed
+11 -11
+11 -11
View File
@@ -573,14 +573,14 @@ void operate_toml_kv_table(const std::vector<toml::table> &arr, const toml::key
{
for(const toml::table &table : arr)
{
const auto &key = table.at(key_name), value = table.at(value_name);
const auto &key = table.at(key_name), &value = table.at(value_name);
binary_op(key, value);
}
}
void readTOMLConf(toml::value &root)
{
const auto &section_common = toml::find(root, "common");
auto section_common = toml::find(root, "common");
string_array default_url, insert_url;
find_if_exist(section_common, "default_url", default_url, "insert_url", insert_url);
@@ -619,7 +619,7 @@ void readTOMLConf(toml::value &root)
safe_set_streams(toml::find_or<RegexMatchConfigs>(root, "userinfo", "stream_rule", RegexMatchConfigs{}));
safe_set_times(toml::find_or<RegexMatchConfigs>(root, "userinfo", "time_rule", RegexMatchConfigs{}));
const auto &section_node_pref = toml::find(root, "node_pref");
auto section_node_pref = toml::find(root, "node_pref");
find_if_exist(section_node_pref,
"udp_flag", global.UDPFlag,
@@ -638,7 +638,7 @@ void readTOMLConf(toml::value &root)
importItems(renameconfs, "rename_node", false);
safe_set_renames(toml::get<RegexMatchConfigs>(toml::value(renameconfs)));
const auto &section_managed = toml::find(root, "managed_config");
auto section_managed = toml::find(root, "managed_config");
find_if_exist(section_managed,
"write_managed_config", global.writeManagedConfig,
@@ -648,13 +648,13 @@ void readTOMLConf(toml::value &root)
"quanx_device_id", global.quanXDevID
);
const auto &section_surge_external = toml::find(root, "surge_external_proxy");
auto section_surge_external = toml::find(root, "surge_external_proxy");
find_if_exist(section_surge_external,
"surge_ssr_path", global.surgeSSRPath,
"resolve_hostname", global.surgeResolveHostname
);
const auto &section_emojis = toml::find(root, "emojis");
auto section_emojis = toml::find(root, "emojis");
find_if_exist(section_emojis,
"add_emoji", global.addEmoji,
@@ -669,7 +669,7 @@ void readTOMLConf(toml::value &root)
importItems(groups, "custom_groups", false);
global.customProxyGroups = toml::get<ProxyGroupConfigs>(toml::value(groups));
const auto &section_ruleset = toml::find(root, "ruleset");
auto section_ruleset = toml::find(root, "ruleset");
find_if_exist(section_ruleset,
"enabled", global.enableRuleGen,
@@ -681,7 +681,7 @@ void readTOMLConf(toml::value &root)
importItems(rulesets, "rulesets", false);
global.customRulesets = toml::get<RulesetConfigs>(toml::value(rulesets));
const auto &section_template = toml::find(root, "template");
auto section_template = toml::find(root, "template");
global.templatePath = toml::find_or(section_template, "template_path", "template");
@@ -702,7 +702,7 @@ void readTOMLConf(toml::value &root)
global.cronTasks = toml::get<CronTaskConfigs>(toml::value(tasks));
refresh_schedule();
const auto &section_server = toml::find(root, "server");
auto section_server = toml::find(root, "server");
find_if_exist(section_server,
"listen", global.listenAddress,
@@ -711,7 +711,7 @@ void readTOMLConf(toml::value &root)
);
webServer.serve_file = !webServer.serve_file_root.empty();
const auto &section_advanced = toml::find(root, "advanced");
auto section_advanced = toml::find(root, "advanced");
std::string log_level;
bool enable_cache = true;
@@ -1135,7 +1135,7 @@ int loadExternalYAML(YAML::Node &node, ExternalConfig &ext)
int loadExternalTOML(toml::value &root, ExternalConfig &ext)
{
const auto &section = toml::find(root, "custom");
auto section = toml::find(root, "custom");
find_if_exist(section,
"enable_rule_generator", ext.enable_rule_generator,