X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7a3a100990355eb757dc81106b5aac6daed0b8e1..95199f4ffa751d3614a07fefe6b3caa6deca1b97:/include/xbt/config.hpp diff --git a/include/xbt/config.hpp b/include/xbt/config.hpp index a4e7517287..236d87f962 100644 --- a/include/xbt/config.hpp +++ b/include/xbt/config.hpp @@ -145,17 +145,19 @@ typename std::enable_if([&value,callback](const T& val) { + callback(val); + value = std::move(val); + } + )); } /** Bind a variable to configuration flag * *

  *  static int x;
- *  simgrid::config::bindFlag(a, "x", [](int x) { return return x > 0; });
+ *  simgrid::config::bindFlag(a, "x", [](int x) { return x > 0; });
  *  
*/ // F is a predicate, F : T const& -> bool @@ -167,18 +169,20 @@ typename std::enable_if([&value, callback](const T& val) { + if (not callback(val)) + throw std::range_error("invalid value."); + value = std::move(val); + }) + ); } /** A variable bound to a CLI option * *

  *  static simgrid::config::flag answer("answer", "Expected answer", 42);
- *  static simgrid::config::flag name("name", "Ford Prefect", "John Doe");
+ *  static simgrid::config::flag name("name", "Ford Perfect", "John Doe");
  *  static simgrid::config::flag gamma("gamma", "Gamma factor", 1.987);
  *  
*/