@@ -505,7 +505,8 @@ class Argument {
505
505
m_values.emplace_back (m_implicit_value);
506
506
std::visit ([](const auto &f) { f ({}); }, m_action);
507
507
return start;
508
- } else if ((dist = static_cast <std::size_t >(std::distance (start, end))) >= num_args_min) {
508
+ }
509
+ if ((dist = static_cast <std::size_t >(std::distance (start, end))) >= num_args_min) {
509
510
if (num_args_max < dist) {
510
511
end = std::next (start, num_args_max);
511
512
}
@@ -525,8 +526,9 @@ class Argument {
525
526
void operator ()(void_action &f) {
526
527
std::for_each (first, last, f);
527
528
if (!self.m_default_value .has_value ()) {
528
- if (!self.m_accepts_optional_like_value )
529
+ if (!self.m_accepts_optional_like_value ) {
529
530
self.m_values .resize (std::distance (first, last));
531
+ }
530
532
}
531
533
}
532
534
@@ -619,9 +621,11 @@ class Argument {
619
621
std::size_t m_max;
620
622
621
623
public:
622
- NArgsRange (std::size_t minimum, std::size_t maximum) : m_min(minimum), m_max(maximum) {
623
- if (minimum > maximum)
624
+ NArgsRange (std::size_t minimum, std::size_t maximum)
625
+ : m_min(minimum), m_max(maximum) {
626
+ if (minimum > maximum) {
624
627
throw std::logic_error (" Range of number of arguments is invalid" );
628
+ }
625
629
}
626
630
627
631
bool contains (std::size_t value) const {
@@ -647,17 +651,17 @@ class Argument {
647
651
648
652
void throw_nargs_range_validation_error () const {
649
653
std::stringstream stream;
650
- if (!m_used_name.empty ())
654
+ if (!m_used_name.empty ()) {
651
655
stream << m_used_name << " : " ;
656
+ }
652
657
if (m_num_args_range.is_exact ()) {
653
658
stream << m_num_args_range.get_min ();
654
659
} else if (m_num_args_range.is_right_bounded ()) {
655
660
stream << m_num_args_range.get_min () << " to " << m_num_args_range.get_max ();
656
661
} else {
657
662
stream << m_num_args_range.get_min () << " or more" ;
658
663
}
659
- stream << " argument(s) expected. "
660
- << m_values.size () << " provided." ;
664
+ stream << " argument(s) expected. " << m_values.size () << " provided." ;
661
665
throw std::runtime_error (stream.str ());
662
666
}
663
667
@@ -862,11 +866,13 @@ class Argument {
862
866
}
863
867
if (m_default_value.has_value ()) {
864
868
return std::any_cast<T>(m_default_value);
865
- } else {
866
- if constexpr (details::IsContainer<T>)
867
- if (!m_accepts_optional_like_value)
868
- return any_cast_container<T>(m_values);
869
869
}
870
+ if constexpr (details::IsContainer<T>) {
871
+ if (!m_accepts_optional_like_value) {
872
+ return any_cast_container<T>(m_values);
873
+ }
874
+ }
875
+
870
876
throw std::logic_error (" No value provided for '" + m_names.back () + " '." );
871
877
}
872
878
0 commit comments