+ bind_flag(value, name, description, std::move(callback));
+ alias(name, aliases);
+}
+
+template <class F>
+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, 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 = val;
+ return;
+ }
+ std::string mesg = "\n";
+ if (val == "help")
+ mesg += std::string("Possible values for option ") + name + ":\n";
+ else
+ mesg += std::string("Invalid value '") + val + "' for option " + name + ". Possible values:\n";
+ for (auto const& kv : valid_values)
+ mesg += " - '" + kv.first + "': " + kv.second + (kv.first == value ? " <=== DEFAULT" : "") + "\n";
+ xbt_die("%s", mesg.c_str());
+ }));
+}
+template <class F>
+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, std::less<>>& valid_values, F callback)
+{
+ bind_flag(value, name, description, valid_values, std::move(callback));
+ alias(name, aliases);