From d40d2fcecf03b345fda2736a0f6ff705ee5e296f Mon Sep 17 00:00:00 2001 From: Oren Cohen Date: Thu, 19 Sep 2024 16:53:54 +0300 Subject: [PATCH] Dont force store_into to override default/explicit values if already set --- include/argparse/argparse.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/argparse/argparse.hpp b/include/argparse/argparse.hpp index 394031d..c3ee214 100644 --- a/include/argparse/argparse.hpp +++ b/include/argparse/argparse.hpp @@ -691,7 +691,9 @@ class Argument { } auto &store_into(bool &var) { - flag(); + if ((!m_default_value.has_value()) && (!m_implicit_value.has_value())) { + flag(); + } if (m_default_value.has_value()) { var = std::any_cast(m_default_value); }