Skip to content

Commit

Permalink
reorder the lexical_conversion definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
phlptp committed Oct 25, 2019
1 parent b77472d commit 034de9f
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions include/CLI/TypeTools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,23 +749,6 @@ bool lexical_conversion(const std::vector<std ::string> &strings, T &output) {
return lexical_assign<T, XC>(strings[0], output);
}

/// Lexical conversion if there is only one element but the conversion type is a vector
template <typename T,
typename XC,
enable_if_t<!is_tuple_like<T>::value && !is_vector<T>::value && is_vector<XC>::value, detail::enabler> =
detail::dummy>
bool lexical_conversion(const std::vector<std ::string> &strings, T &output) {

if(strings.size() > 1 || (!strings.empty() && !(strings.front().empty()))) {
XC val;
auto retval = lexical_conversion<XC, XC>(strings, val);
output = T{val};
return retval;
}
output = T{};
return true;
}

/// Lexical conversion if there is only one element but the conversion type is for two call a two element constructor
template <typename T,
typename XC,
Expand Down Expand Up @@ -844,6 +827,23 @@ bool lexical_conversion(const std::vector<std ::string> &strings, T &output) {
}
return (!output.empty()) && retval;
}
// This one is last since it can call other lexical_conversion functions
/// Lexical conversion if there is only one element but the conversion type is a vector
template <typename T,
typename XC,
enable_if_t<!is_tuple_like<T>::value && !is_vector<T>::value && is_vector<XC>::value, detail::enabler> =
detail::dummy>
bool lexical_conversion(const std::vector<std ::string> &strings, T &output) {

if(strings.size() > 1 || (!strings.empty() && !(strings.front().empty()))) {
XC val;
auto retval = lexical_conversion<XC, XC>(strings, val);
output = T{val};
return retval;
}
output = T{};
return true;
}

/// function template for converting tuples if the static Index is greater than the tuple size
template <class T, class XC, std::size_t I>
Expand Down

0 comments on commit 034de9f

Please sign in to comment.