From 5343203035034c0e4e1b894ca313a072c58d9183 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Fri, 30 Mar 2018 23:59:02 +0200 Subject: [PATCH] config: fix declareFlag template --- include/xbt/config.hpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/include/xbt/config.hpp b/include/xbt/config.hpp index d457e57a4e..6c61a46bef 100644 --- a/include/xbt/config.hpp +++ b/include/xbt/config.hpp @@ -146,10 +146,12 @@ typename std::enable_if([&value,callback](const T& val) { + callback(val); + value = std::move(val); + } + )); } /** Bind a variable to configuration flag @@ -168,11 +170,13 @@ 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 -- 2.20.1