Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / include / xbt / config.hpp
index eeca225..ac6c292 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2016-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -132,7 +132,7 @@ void bind_flag(T& value, const char* name, std::initializer_list<const char*> al
  */
 // F is a checker, F : T& -> ()
 template <class T, class F>
-typename std::enable_if<std::is_same<void, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>::type
+typename std::enable_if_t<std::is_same<void, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>
 bind_flag(T& value, const char* name, const char* description, F callback)
 {
   declare_flag(name, description, value, std::function<void(const T&)>([&value, callback](const T& val) {
@@ -142,7 +142,7 @@ bind_flag(T& value, const char* name, const char* description, F callback)
 }
 
 template <class T, class F>
-typename std::enable_if<std::is_same<void, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>::type
+typename std::enable_if_t<std::is_same<void, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>
 bind_flag(T& value, const char* name, std::initializer_list<const char*> aliases, const char* description, F callback)
 {
   bind_flag(value, name, description, std::move(callback));
@@ -150,16 +150,16 @@ bind_flag(T& value, const char* name, std::initializer_list<const char*> aliases
 }
 
 template <class F>
-typename std::enable_if<std::is_same<void, decltype(std::declval<F>()(std::declval<const std::string&>()))>::value,
-                        void>::type
+typename std::enable_if_t<std::is_same<void, decltype(std::declval<F>()(std::declval<const std::string&>()))>::value,
+                          void>
 bind_flag(std::string& value, const char* name, const char* description,
-          const std::map<std::string, std::string>& valid_values, F callback)
+          const std::map<std::string, std::string, std::less<>>& valid_values, F callback)
 {
   declare_flag(name, description, value,
                std::function<void(const std::string&)>([&value, name, valid_values, callback](const std::string& val) {
                  callback(val);
                  if (valid_values.find(val) != valid_values.end()) {
-                   value = std::move(val);
+                   value = val;
                    return;
                  }
                  std::string mesg = "\n";
@@ -173,10 +173,10 @@ bind_flag(std::string& value, const char* name, const char* description,
                }));
 }
 template <class F>
-typename std::enable_if<std::is_same<void, decltype(std::declval<F>()(std::declval<const std::string&>()))>::value,
-                        void>::type
+typename std::enable_if_t<std::is_same<void, decltype(std::declval<F>()(std::declval<const std::string&>()))>::value,
+                          void>
 bind_flag(std::string& value, const char* name, std::initializer_list<const char*> aliases, const char* description,
-          const std::map<std::string, std::string>& valid_values, F callback)
+          const std::map<std::string, std::string, std::less<>>& valid_values, F callback)
 {
   bind_flag(value, name, description, valid_values, std::move(callback));
   alias(name, aliases);
@@ -191,7 +191,7 @@ bind_flag(std::string& value, const char* name, std::initializer_list<const char
  */
 // F is a predicate, F : T const& -> bool
 template <class T, class F>
-typename std::enable_if<std::is_same<bool, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>::type
+typename std::enable_if_t<std::is_same<bool, decltype(std::declval<F>()(std::declval<const T&>()))>::value, void>
 bind_flag(T& value, const char* name, const char* description, F callback)
 {
   declare_flag(name, description, value, std::function<void(const T&)>([&value, callback](const T& val) {
@@ -252,16 +252,17 @@ public:
    * and producing an informative error message when an invalid value is passed, or when help is passed as a value.
    */
   template <class F>
-  Flag(const char* name, const char* desc, T value, const std::map<std::string, std::string>& valid_values, F callback)
+  Flag(const char* name, const char* desc, T value, const std::map<std::string, std::string, std::less<>>& valid_values,
+       F callback)
       : value_(value), name_(name)
   {
-    simgrid::config::bind_flag(value_, name, desc, std::move(valid_values), std::move(callback));
+    simgrid::config::bind_flag(value_, name, desc, valid_values, std::move(callback));
   }
 
   /* A constructor with everything */
   template <class F>
   Flag(const char* name, std::initializer_list<const char*> aliases, const char* desc, T value,
-       const std::map<std::string, std::string>& valid_values, F callback)
+       const std::map<std::string, std::string, std::less<>>& valid_values, F callback)
       : value_(value), name_(name)
   {
     simgrid::config::bind_flag(value_, name, aliases, desc, valid_values, std::move(callback));