- std::function<void(const T&)>([&value,callback](const T& val) {
- callback(val);
- value = std::move(val);
- }
- ));
+ std::function<void(const T&)>([&value, name, valid_values, callback](const T& val) {
+ callback(val);
+ bool found = false;
+ for (auto kv : valid_values) {
+ if (kv.first == val)
+ found = true;
+ }
+ if (not found || std::string(val) == "help") {
+ std::string mesg;
+ if (std::string(val) == "help")
+ mesg = std::string("\nPossible values for option ") + name + ":\n";
+ else
+ mesg = std::string("\nInvalid value '") + val + "' for option " + name + ". Possible values:\n";
+ for (auto kv : valid_values)
+ mesg += " - '" + std::string(kv.first) + "': " + kv.second +
+ (kv.first == value ? " <=== DEFAULT" : "") + "\n";
+ xbt_die("%s", mesg.c_str());
+ }
+ value = std::move(val);
+ }));