From f10ee369ee44f7ecb631e452456c8e61dda734b3 Mon Sep 17 00:00:00 2001 From: Philip Top Date: Sat, 29 Nov 2025 05:49:47 -0800 Subject: [PATCH] Issue #1258 (#1261) fix an issue where an enumeration with a stream output method would generate strings that could not be converted back to the original enumeration value. Fixes Issue #1258 recent changes fixed a few issues with the default_val method. The method used the to_string, which in cases where a user supplied a streaming operation to enumerations they could not be converted back to the enumeration properly resulting in some errors and confusing help output. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- include/CLI/ExtraValidators.hpp | 4 +++- include/CLI/Option.hpp | 2 +- tests/TransformTest.cpp | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/CLI/ExtraValidators.hpp b/include/CLI/ExtraValidators.hpp index e861eb41..481ded45 100644 --- a/include/CLI/ExtraValidators.hpp +++ b/include/CLI/ExtraValidators.hpp @@ -358,7 +358,9 @@ class CheckedTransformer : public Validator { out += detail::generate_map(detail::smart_deref(mapping)) + " OR {"; out += detail::join( detail::smart_deref(mapping), - [](const iteration_type_t &v) { return detail::to_string(detail::pair_adaptor::second(v)); }, + [](const iteration_type_t &v) { + return detail::value_string(detail::pair_adaptor::second(v)); + }, ","); out.push_back('}'); return out; diff --git a/include/CLI/Option.hpp b/include/CLI/Option.hpp index e9b7714a..9cc7284d 100644 --- a/include/CLI/Option.hpp +++ b/include/CLI/Option.hpp @@ -815,7 +815,7 @@ class Option : public OptionBase