From 27ea8d78c124dd6b7cdb649b8d2bb95dc16f4cde Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 25 Jan 2021 13:21:17 +0100 Subject: [PATCH] Use auto return type deduction. --- src/mc/mc_replay.hpp | 2 +- src/surf/surf_interface.cpp | 7 ------- src/surf/surf_interface.hpp | 8 +++++++- src/xbt/log.cpp | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/mc/mc_replay.hpp b/src/mc/mc_replay.hpp index 4d093624e1..823d93e6f4 100644 --- a/src/mc/mc_replay.hpp +++ b/src/mc/mc_replay.hpp @@ -13,7 +13,7 @@ * This is using the format generated by traceToString(). * Use a function to avoid static initialization order fiasco. */ -inline std::string& MC_record_path() +inline auto& MC_record_path() { static std::string value; return value; diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index fd6fc5e3e0..2f74981b97 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -34,13 +34,6 @@ std::vector all_existing_models; /* to destro simgrid::kernel::profile::FutureEvtSet future_evt_set; std::vector surf_path; -/** set of hosts for which one want to be notified if they ever restart */ -std::set>& watched_hosts() // avoid static initialization order fiasco -{ - static std::set> value; - return value; -} - extern std::map> storage_types; std::vector* surf_plugin_description = nullptr; diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 0845b54fc0..82137d8682 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -30,7 +30,13 @@ extern XBT_PRIVATE double sg_bandwidth_factor; extern XBT_PRIVATE double sg_weight_S_parameter; extern XBT_PRIVATE std::vector surf_path; extern XBT_PRIVATE std::unordered_map traces_set_list; -XBT_PRIVATE std::set>& watched_hosts(); + +/** set of hosts for which one want to be notified if they ever restart */ +inline auto& watched_hosts() // avoid static initialization order fiasco +{ + static std::set> value; + return value; +} static inline void double_update(double* variable, double value, double precision) { diff --git a/src/xbt/log.cpp b/src/xbt/log.cpp index fd8afa045b..fa02f97812 100644 --- a/src/xbt/log.cpp +++ b/src/xbt/log.cpp @@ -39,7 +39,7 @@ struct xbt_log_setting_t { }; // This function is here to avoid static initialization order fiasco -static std::vector& xbt_log_settings() +static auto& xbt_log_settings() { static std::vector value; return value; -- 2.20.1