Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[config] Add a template declareFlag<T>(...)
authorGabriel Corona <gabriel.corona@loria.fr>
Thu, 28 Apr 2016 13:20:46 +0000 (15:20 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Thu, 28 Apr 2016 13:36:27 +0000 (15:36 +0200)
include/xbt/config.hpp

index 42f8fdf..1be433b 100644 (file)
@@ -98,6 +98,14 @@ inline std::string to_string(std::string&& value)
 XBT_PUBLIC(void) declareFlag(const char* name, const char* description,
   std::function<void(const char* value)> callback);
 
+template<class T, class F>
+XBT_PUBLIC(void) declareFlag(const char* name, const char* description, F callback)
+{
+  declareFlag(name, description, [callback](const char* value) {
+    callback(parse<T>(value));
+  });
+}
+
 /** Bind a variable to configuration flag
  *
  *  @param value Bound variable