42template <
bool B,
class T =
void>
using enable_if_t =
typename std::enable_if<B, T>::type;
51template <
bool B,
class T,
class F>
using conditional_t =
typename std::conditional<B, T, F>::type;
54template <
typename T>
struct is_bool : std::false_type {};
57template <>
struct is_bool<bool> : std::true_type {};
63template <
typename T>
struct is_shared_ptr<std::shared_ptr<T>> : std::true_type {};
66template <
typename T>
struct is_shared_ptr<const std::shared_ptr<T>> : std::true_type {};
89template <
typename T>
struct element_type<T, typename std::enable_if<is_copyable_ptr<T>::value>::type> {
90 using type =
typename std::pointer_traits<T>::element_type;
98template <
typename T,
typename _ =
void>
struct pair_adaptor : std::false_type {
100 using first_type =
typename std::remove_const<value_type>::type;
104 template <
typename Q>
static auto first(Q &&pair_value) ->
decltype(std::forward<Q>(pair_value)) {
105 return std::forward<Q>(pair_value);
108 template <
typename Q>
static auto second(Q &&pair_value) ->
decltype(std::forward<Q>(pair_value)) {
109 return std::forward<Q>(pair_value);
121 using first_type =
typename std::remove_const<typename value_type::first_type>::type;
122 using second_type =
typename std::remove_const<typename value_type::second_type>::type;
125 template <
typename Q>
static auto first(Q &&pair_value) ->
decltype(std::get<0>(std::forward<Q>(pair_value))) {
126 return std::get<0>(std::forward<Q>(pair_value));
129 template <
typename Q>
static auto second(Q &&pair_value) ->
decltype(std::get<1>(std::forward<Q>(pair_value))) {
130 return std::get<1>(std::forward<Q>(pair_value));
141#pragma GCC diagnostic push
142#pragma GCC diagnostic ignored "-Wnarrowing"
146 template <
typename TT,
typename CC>
147 static auto test(
int, std::true_type) ->
decltype(
150#pragma diag_suppress 2361
152 TT { std::declval<CC>() }
154#pragma diag_default 2361
157 std::is_move_assignable<TT>());
159 template <
typename TT,
typename CC>
static auto test(
int, std::false_type) -> std::false_type;
161 template <
typename,
typename>
static auto test(...) -> std::false_type;
164 static constexpr bool value =
decltype(test<T, C>(0,
typename std::is_constructible<T, C>::type()))
::value;
167#pragma GCC diagnostic pop
174 template <
typename TT,
typename SS>
175 static auto test(
int) ->
decltype(std::declval<SS &>() << std::declval<TT>(), std::true_type());
177 template <
typename,
typename>
static auto test(...) -> std::false_type;
185 template <
typename TT,
typename SS>
186 static auto test(
int) ->
decltype(std::declval<SS &>() >> std::declval<TT &>(), std::true_type());
188 template <
typename,
typename>
static auto test(...) -> std::false_type;
196 template <
typename TT>
197 static auto test(
int) ->
decltype(std::declval<TT>().real(), std::declval<TT>().imag(), std::true_type());
199 template <
typename>
static auto test(...) -> std::false_type;
208 std::istringstream is;
211 return !is.fail() && !is.rdbuf()->in_avail();
229 void_t<typename T::value_type,
230 decltype(std::declval<T>().end()),
231 decltype(std::declval<T>().clear()),
232 decltype(std::declval<T>().insert(std::declval<decltype(std::declval<T>().end())>(),
233 std::declval<const typename T::value_type &>()))>,
235 :
public conditional_t<std::is_constructible<T, std::string>::value, std::false_type, std::true_type> {};
247 :
public std::true_type {};
250template <
typename T,
typename _ =
void>
struct is_wrapper : std::false_type {};
258 template <
typename SS>
261 static auto test(
int) ->
decltype(std::tuple_size<typename std::decay<SS>::type>
::value, std::true_type{});
262 template <
typename>
static auto test(...) -> std::false_type;
270auto to_string(T &&value) ->
decltype(std::forward<T>(value)) {
271 return std::forward<T>(value);
279 return std::string(value);
288 std::stringstream stream;
296 !is_readable_container<typename std::remove_const<T>::type>::value,
299 return std::string{};
305 is_readable_container<T>::value,
308 auto cval = variable.begin();
309 auto end = variable.end();
311 return std::string(
"{}");
313 std::vector<std::string> defaults;
322template <
typename T1,
327 return to_string(std::forward<T>(value));
331template <
typename T1,
336 return std::string{};
341 return std::to_string(value);
346 return std::to_string(
static_cast<typename std::underlying_type<T>::type
>(value));
356template <
typename T,
typename def,
typename Enable =
void>
struct wrapped_type {
using type = def; };
359template <
typename T,
typename def>
struct wrapped_type<T, def, typename std::enable_if<is_wrapper<T>::value>::type> {
360 using type =
typename T::value_type;
369 typename std::enable_if<!is_tuple_like<T>::value && !is_mutable_container<T>::value &&
370 !std::is_void<T>::value>::type> {
376struct type_count_base<T, typename std::enable_if<is_tuple_like<T>::value && !is_mutable_container<T>::value>::type> {
377 static constexpr int value{std::tuple_size<T>::value};
381template <
typename T>
struct type_count_base<T, typename std::enable_if<is_mutable_container<T>::value>::type> {
394template <
typename T,
typename Enable =
void>
struct type_count {
static const int value{0}; };
399 typename std::enable_if<!is_wrapper<T>::value && !is_tuple_like<T>::value && !is_complex<T>::value &&
400 !std::is_void<T>::value>::type> {
405template <
typename T>
struct type_count<T, typename std::enable_if<is_complex<T>::value>::type> {
410template <
typename T>
struct type_count<T, typename std::enable_if<is_mutable_container<T>::value>::type> {
417 typename std::enable_if<is_wrapper<T>::value && !is_complex<T>::value && !is_tuple_like<T>::value &&
418 !is_mutable_container<T>::value>::type> {
423template <
typename T, std::
size_t I>
424constexpr typename std::enable_if<I == type_count_base<T>::value,
int>::type
tuple_type_size() {
429template <
typename T, std::
size_t I>
430 constexpr typename std::enable_if < I<type_count_base<T>::value,
int>::type
tuple_type_size() {
435template <
typename T>
struct type_count<T, typename std::enable_if<is_tuple_like<T>::value>::type> {
440template <
typename T>
struct subtype_count {
445template <
typename T,
typename Enable =
void>
struct type_count_min {
static const int value{0}; };
449struct type_count_min<
451 typename std::enable_if<!is_mutable_container<T>::value && !is_tuple_like<T>::value && !is_wrapper<T>::value &&
452 !is_complex<T>::value && !std::is_void<T>::value>::type> {
453 static constexpr int value{type_count<T>::value};
457template <
typename T>
struct type_count_min<T, typename std::enable_if<is_complex<T>::value>::type> {
458 static constexpr int value{1};
463struct type_count_min<
465 typename std::enable_if<is_wrapper<T>::value && !is_complex<T>::value && !is_tuple_like<T>::value>::type> {
466 static constexpr int value{subtype_count_min<typename T::value_type>::value};
470template <
typename T, std::
size_t I>
471constexpr typename std::enable_if<I == type_count_base<T>::value,
int>::type tuple_type_size_min() {
476template <
typename T, std::
size_t I>
477 constexpr typename std::enable_if < I<type_count_base<T>::value,
int>::type tuple_type_size_min() {
478 return subtype_count_min<typename std::tuple_element<I, T>::type>::value + tuple_type_size_min<T, I + 1>();
482template <
typename T>
struct type_count_min<T, typename std::enable_if<is_tuple_like<T>::value>::type> {
483 static constexpr int value{tuple_type_size_min<T, 0>()};
487template <
typename T>
struct subtype_count_min {
488 static constexpr int value{is_mutable_container<T>::value
490 : type_count_min<T>::value};
494template <
typename T,
typename Enable =
void>
struct expected_count {
static const int value{0}; };
498struct expected_count<T,
499 typename std::enable_if<!is_mutable_container<T>::value && !is_wrapper<T>::value &&
500 !std::is_void<T>::value>::type> {
501 static constexpr int value{1};
504template <
typename T>
struct expected_count<T, typename std::enable_if<is_mutable_container<T>::value>::type> {
510struct expected_count<T, typename std::enable_if<!is_mutable_container<T>::value && is_wrapper<T>::value>::type> {
511 static constexpr int value{expected_count<typename T::value_type>::value};
515enum class object_category :
int {
518 unsigned_integral = 4,
522 number_constructible = 12,
523 double_constructible = 14,
524 integer_constructible = 16,
526 string_assignable = 23,
527 string_constructible = 24,
533 container_value = 80,
540template <
typename T,
typename Enable =
void>
struct classify_object {
541 static constexpr object_category value{object_category::other};
546struct classify_object<
548 typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, char>::value && std::is_signed<T>::value &&
549 !is_bool<T>::value && !std::is_enum<T>::value>::type> {
550 static constexpr object_category value{object_category::integral_value};
555struct classify_object<T,
556 typename std::enable_if<std::is_integral<T>::value && std::is_unsigned<T>::value &&
557 !std::is_same<T, char>::value && !is_bool<T>::value>::type> {
558 static constexpr object_category value{object_category::unsigned_integral};
563struct classify_object<T, typename std::enable_if<std::is_same<T, char>::value && !std::is_enum<T>::value>::type> {
564 static constexpr object_category value{object_category::char_value};
568template <
typename T>
struct classify_object<T, typename std::enable_if<is_bool<T>::value>::type> {
569 static constexpr object_category value{object_category::boolean_value};
573template <
typename T>
struct classify_object<T, typename std::enable_if<std::is_floating_point<T>::value>::type> {
574 static constexpr object_category value{object_category::floating_point};
579struct classify_object<T,
580 typename std::enable_if<!std::is_floating_point<T>::value && !std::is_integral<T>::value &&
581 std::is_assignable<T &, std::string>::value>::type> {
582 static constexpr object_category value{object_category::string_assignable};
587struct classify_object<
589 typename std::enable_if<!std::is_floating_point<T>::value && !std::is_integral<T>::value &&
590 !std::is_assignable<T &, std::string>::value && (type_count<T>::value == 1) &&
591 std::is_constructible<T, std::string>::value>::type> {
592 static constexpr object_category value{object_category::string_constructible};
596template <
typename T>
struct classify_object<T, typename std::enable_if<std::is_enum<T>::value>::type> {
597 static constexpr object_category value{object_category::enumeration};
600template <
typename T>
struct classify_object<T, typename std::enable_if<is_complex<T>::value>::type> {
601 static constexpr object_category value{object_category::complex_number};
606template <
typename T>
struct uncommon_type {
607 using type =
typename std::conditional<!std::is_floating_point<T>::value && !std::is_integral<T>::value &&
608 !std::is_assignable<T &, std::string>::value &&
609 !std::is_constructible<T, std::string>::value && !is_complex<T>::value &&
610 !is_mutable_container<T>::value && !std::is_enum<T>::value,
612 std::false_type>::type;
613 static constexpr bool value = type::value;
618struct classify_object<T,
619 typename std::enable_if<(!is_mutable_container<T>::value && is_wrapper<T>::value &&
620 !is_tuple_like<T>::value && uncommon_type<T>::value)>::type> {
621 static constexpr object_category value{object_category::wrapper_value};
626struct classify_object<T,
627 typename std::enable_if<uncommon_type<T>::value && type_count<T>::value == 1 &&
628 !is_wrapper<T>::value && is_direct_constructible<T, double>::value &&
629 is_direct_constructible<T, int>::value>::type> {
630 static constexpr object_category value{object_category::number_constructible};
635struct classify_object<T,
636 typename std::enable_if<uncommon_type<T>::value && type_count<T>::value == 1 &&
637 !is_wrapper<T>::value && !is_direct_constructible<T, double>::value &&
638 is_direct_constructible<T, int>::value>::type> {
639 static constexpr object_category value{object_category::integer_constructible};
644struct classify_object<T,
645 typename std::enable_if<uncommon_type<T>::value && type_count<T>::value == 1 &&
646 !is_wrapper<T>::value && is_direct_constructible<T, double>::value &&
647 !is_direct_constructible<T, int>::value>::type> {
648 static constexpr object_category value{object_category::double_constructible};
653struct classify_object<
655 typename std::enable_if<is_tuple_like<T>::value &&
656 ((type_count<T>::value >= 2 && !is_wrapper<T>::value) ||
657 (uncommon_type<T>::value && !is_direct_constructible<T, double>::value &&
658 !is_direct_constructible<T, int>::value))>::type> {
659 static constexpr object_category value{object_category::tuple_value};
668template <
typename T>
struct classify_object<T, typename std::enable_if<is_mutable_container<T>::value>::type> {
669 static constexpr object_category value{object_category::container_value};
680constexpr const char *type_name() {
685 enable_if_t<classify_object<T>::value == object_category::integral_value ||
686 classify_object<T>::value == object_category::integer_constructible,
688constexpr const char *type_name() {
694constexpr const char *type_name() {
699 enable_if_t<classify_object<T>::value == object_category::floating_point ||
700 classify_object<T>::value == object_category::number_constructible ||
701 classify_object<T>::value == object_category::double_constructible,
703constexpr const char *type_name() {
710constexpr const char *type_name() {
717constexpr const char *type_name() {
724constexpr const char *type_name() {
730 enable_if_t<classify_object<T>::value >= object_category::string_assignable &&
731 classify_object<T>::value <= object_category::other,
733constexpr const char *type_name() {
740std::string type_name();
744 enable_if_t<classify_object<T>::value == object_category::container_value ||
745 classify_object<T>::value == object_category::wrapper_value,
747std::string type_name();
753inline std::string type_name() {
754 return type_name<typename std::decay<typename std::tuple_element<0, T>::type>::type>();
758template <
typename T, std::
size_t I>
759inline typename std::enable_if<I == type_count_base<T>::value, std::string>::type tuple_name() {
760 return std::string{};
764template <
typename T, std::
size_t I>
765inline typename std::enable_if<(I < type_count_base<T>::value), std::string>::type tuple_name() {
766 std::string str = std::string(type_name<
typename std::decay<
typename std::tuple_element<I, T>::type>::type>()) +
767 ',' + tuple_name<T, I + 1>();
768 if(str.back() ==
',')
777inline std::string type_name() {
778 auto tname = std::string(1,
'[') + tuple_name<T, 0>();
779 tname.push_back(
']');
785 enable_if_t<classify_object<T>::value == object_category::container_value ||
786 classify_object<T>::value == object_category::wrapper_value,
788inline std::string type_name() {
789 return type_name<typename T::value_type>();
801 std::uint64_t output_ll = std::strtoull(input.c_str(), &val, 0);
802 output =
static_cast<T
>(output_ll);
803 if(val == (input.c_str() + input.size()) &&
static_cast<std::uint64_t
>(
output) == output_ll) {
807 std::int64_t output_sll = std::strtoll(input.c_str(), &val, 0);
808 if(val == (input.c_str() + input.size())) {
809 output = (output_sll < 0) ? static_cast<T>(0) : static_cast<T>(output_sll);
810 return (
static_cast<std::int64_t
>(
output) == output_sll);
822 std::int64_t output_ll = std::strtoll(input.c_str(), &val, 0);
823 output =
static_cast<T
>(output_ll);
824 if(val == (input.c_str() + input.size()) &&
static_cast<std::int64_t
>(
output) == output_ll) {
827 if(input ==
"true") {
829 output =
static_cast<T
>(1);
837 static const std::string trueString(
"true");
838 static const std::string falseString(
"false");
839 if(val == trueString) {
842 if(val == falseString) {
847 if(val.size() == 1) {
848 if(val[0] >=
'1' && val[0] <=
'9') {
849 return (
static_cast<std::int64_t
>(val[0]) -
'0');
864 throw std::invalid_argument(
"unrecognized character");
868 if(val == trueString || val ==
"on" || val ==
"yes" || val ==
"enable") {
870 }
else if(val == falseString || val ==
"off" || val ==
"no" || val ==
"disable") {
873 ret = std::stoll(val);
881 classify_object<T>::value == object_category::unsigned_integral,
891 if(input.size() == 1) {
892 output =
static_cast<T
>(input[0]);
906 }
catch(
const std::invalid_argument &) {
908 }
catch(
const std::out_of_range &) {
911 output = (input[0] !=
'-');
924 auto output_ld = std::strtold(input.c_str(), &val);
925 output =
static_cast<T
>(output_ld);
926 return val == (input.c_str() + input.size());
937 auto nloc = str1.find_last_of(
"+-");
938 if(nloc != std::string::npos && nloc > 0) {
940 str1 = str1.substr(nloc);
941 if(str1.back() ==
'i' || str1.back() ==
'j')
945 if(str1.back() ==
'i' || str1.back() ==
'j') {
982 typename std::underlying_type<T>::type val;
986 output =
static_cast<T
>(val);
992 enable_if_t<classify_object<T>::value == object_category::wrapper_value &&
993 std::is_assignable<T &, typename T::value_type>::value,
996 typename T::value_type val;
1004template <
typename T,
1005 enable_if_t<classify_object<T>::value == object_category::wrapper_value &&
1006 !std::is_assignable<T &, typename T::value_type>::value && std::is_assignable<T &, T>::value,
1009 typename T::value_type val;
1063template <
typename T,
1064 enable_if_t<classify_object<T>::value == object_category::other && std::is_assignable<T &, int>::value,
1070#pragma warning(push)
1071#pragma warning(disable : 4800)
1089template <
typename T,
1090 enable_if_t<classify_object<T>::value == object_category::other && !std::is_assignable<T &, int>::value,
1094 "option object type must have a lexical cast overload or streaming input operator(>>) defined, if it "
1095 "is convertible from another type use the add_option<T, XC>(...) with XC being the known type");
1101template <
typename AssignTo,
1103 enable_if_t<std::is_same<AssignTo, ConvertTo>::value &&
1104 (classify_object<AssignTo>::value == object_category::string_assignable ||
1105 classify_object<AssignTo>::value == object_category::string_constructible),
1112template <
typename AssignTo,
1115 classify_object<AssignTo>::value != object_category::string_assignable &&
1116 classify_object<AssignTo>::value != object_category::string_constructible,
1128template <
typename AssignTo,
1130 enable_if_t<std::is_same<AssignTo, ConvertTo>::value && !std::is_assignable<AssignTo &, AssignTo>::value &&
1131 classify_object<AssignTo>::value == object_category::wrapper_value,
1135 typename AssignTo::value_type emptyVal{};
1144template <
typename AssignTo,
1146 enable_if_t<std::is_same<AssignTo, ConvertTo>::value && !std::is_assignable<AssignTo &, AssignTo>::value &&
1147 classify_object<AssignTo>::value != object_category::wrapper_value &&
1148 std::is_assignable<AssignTo &, int>::value,
1164template <
typename AssignTo,
1166 enable_if_t<!std::is_same<AssignTo, ConvertTo>::value && std::is_assignable<AssignTo &, ConvertTo &>::value,
1174 return parse_result;
1181 enable_if_t<!std::is_same<AssignTo, ConvertTo>::value && !std::is_assignable<AssignTo &, ConvertTo &>::value &&
1182 std::is_move_assignable<AssignTo>::value,
1190 return parse_result;
1194template <
typename AssignTo,
1196 enable_if_t<classify_object<ConvertTo>::value <= object_category::other &&
1197 classify_object<AssignTo>::value <= object_category::wrapper_value,
1199bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &
output) {
1205template <
typename AssignTo,
1210bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &
output) {
1212 typename std::remove_const<typename std::tuple_element<0, ConvertTo>::type>::type v1;
1213 typename std::tuple_element<1, ConvertTo>::type v2;
1215 if(strings.size() > 1) {
1219 output = AssignTo{v1, v2};
1225template <
class AssignTo,
1227 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1230bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &
output) {
1232 if(strings.size() == 1 && strings[0] ==
"{}") {
1235 bool skip_remaining =
false;
1236 if(strings.size() == 2 && strings[0] ==
"{}" &&
is_separator(strings[1])) {
1237 skip_remaining =
true;
1239 for(
const auto &elem : strings) {
1240 typename AssignTo::value_type out;
1246 if(skip_remaining) {
1250 return (!
output.empty());
1255bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &
output) {
1257 if(strings.size() >= 2 && !strings[1].empty()) {
1260 auto str1 = strings[1];
1261 if(str1.back() ==
'i' || str1.back() ==
'j') {
1266 output = ConvertTo{x, y};
1275template <
class AssignTo,
1277 enable_if_t<is_mutable_container<AssignTo>::value && (expected_count<ConvertTo>::value == 1) &&
1280bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &
output) {
1283 output.reserve(strings.size());
1284 for(
const auto &elem : strings) {
1289 return (!
output.empty()) && retval;
1295template <
class AssignTo,
1297 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1300bool lexical_conversion(std::vector<std::string> strings, AssignTo &
output);
1303template <
class AssignTo,
1305 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1310bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &
output);
1313template <
class AssignTo,
1319bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &
output);
1323template <
typename AssignTo,
1325 enable_if_t<!is_tuple_like<AssignTo>::value && !is_mutable_container<AssignTo>::value &&
1326 classify_object<ConvertTo>::value != object_category::wrapper_value &&
1329bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &
output) {
1331 if(strings.size() > 1 || (!strings.empty() && !(strings.front().empty()))) {
1333 auto retval = lexical_conversion<ConvertTo, ConvertTo>(strings, val);
1342template <
class AssignTo,
class ConvertTo, std::
size_t I>
1344tuple_conversion(
const std::vector<std::string> &, AssignTo &) {
1349template <
class AssignTo,
class ConvertTo>
1351tuple_type_conversion(std::vector<std::string> &strings, AssignTo &
output) {
1353 strings.erase(strings.begin());
1358template <
class AssignTo,
class ConvertTo>
1362tuple_type_conversion(std::vector<std::string> &strings, AssignTo &
output) {
1363 auto retval = lexical_conversion<AssignTo, ConvertTo>(strings,
output);
1369template <
class AssignTo,
class ConvertTo>
1370inline typename std::enable_if<is_mutable_container<ConvertTo>::value ||
1373tuple_type_conversion(std::vector<std::string> &strings, AssignTo &
output) {
1375 std::size_t index{subtype_count_min<ConvertTo>::value};
1376 const std::size_t mx_count{subtype_count<ConvertTo>::value};
1377 const std::size_t mx{(std::max)(mx_count, strings.size())};
1385 bool retval = lexical_conversion<AssignTo, ConvertTo>(
1386 std::vector<std::string>(strings.begin(), strings.begin() +
static_cast<std::ptrdiff_t
>(index)),
output);
1387 strings.erase(strings.begin(), strings.begin() +
static_cast<std::ptrdiff_t
>(index) + 1);
1392template <
class AssignTo,
class ConvertTo, std::
size_t I>
1393inline typename std::enable_if<(I < type_count_base<AssignTo>::value),
bool>::type
1394tuple_conversion(std::vector<std::string> strings, AssignTo &
output) {
1396 using ConvertToElement =
typename std::
1397 conditional<is_tuple_like<ConvertTo>::value,
typename std::tuple_element<I, ConvertTo>::type, ConvertTo>::type;
1398 if(!strings.empty()) {
1399 retval = retval && tuple_type_conversion<typename std::tuple_element<I, AssignTo>::type, ConvertToElement>(
1400 strings, std::get<I>(
output));
1402 retval = retval && tuple_conversion<AssignTo, ConvertTo, I + 1>(std::move(strings),
output);
1407template <
class AssignTo,
1409 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1412bool lexical_conversion(std::vector<std::string> strings, AssignTo &
output) {
1414 while(!strings.empty()) {
1416 typename std::remove_const<typename std::tuple_element<0, typename ConvertTo::value_type>::type>::type v1;
1417 typename std::tuple_element<1, typename ConvertTo::value_type>::type v2;
1418 bool retval = tuple_type_conversion<decltype(v1), decltype(v1)>(strings, v1);
1419 if(!strings.empty()) {
1420 retval = retval && tuple_type_conversion<decltype(v2), decltype(v2)>(strings, v2);
1423 output.insert(
output.end(),
typename AssignTo::value_type{v1, v2});
1428 return (!
output.empty());
1432template <
class AssignTo,
1438bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &
output) {
1441 "if the conversion type is defined as a tuple it must be the same size as the type you are converting to");
1442 return tuple_conversion<AssignTo, ConvertTo, 0>(strings,
output);
1446template <
class AssignTo,
1448 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1453bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &
output) {
1456 std::vector<std::string> temp;
1458 std::size_t icount{0};
1460 auto ii_max = strings.size();
1461 while(ii < ii_max) {
1462 temp.push_back(strings[ii]);
1465 if(icount == xcm ||
is_separator(temp.back()) || ii == ii_max) {
1466 if(
static_cast<int>(xcm) > type_count_min<ConvertTo>::value &&
is_separator(temp.back())) {
1469 typename AssignTo::value_type temp_out;
1471 lexical_conversion<typename AssignTo::value_type, typename ConvertTo::value_type>(temp, temp_out);
1484template <
typename AssignTo,
1486 enable_if_t<classify_object<ConvertTo>::value == object_category::wrapper_value &&
1487 std::is_assignable<ConvertTo &, ConvertTo>::value,
1489bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &
output) {
1490 if(strings.empty() || strings.front().empty()) {
1494 typename ConvertTo::value_type val;
1495 if(lexical_conversion<typename ConvertTo::value_type, typename ConvertTo::value_type>(strings, val)) {
1503template <
typename AssignTo,
1505 enable_if_t<classify_object<ConvertTo>::value == object_category::wrapper_value &&
1506 !std::is_assignable<AssignTo &, ConvertTo>::value,
1508bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &
output) {
1509 using ConvertType =
typename ConvertTo::value_type;
1510 if(strings.empty() || strings.front().empty()) {
1515 if(lexical_conversion<typename ConvertTo::value_type, typename ConvertTo::value_type>(strings, val)) {
1523inline std::string sum_string_vector(
const std::vector<std::string> &values) {
1527 for(
const auto &arg : values) {
1533 }
catch(
const std::exception &) {
1541 for(
const auto &arg : values) {
1545 if(val <=
static_cast<double>(std::numeric_limits<std::int64_t>::min()) ||
1546 val >=
static_cast<double>(std::numeric_limits<std::int64_t>::max()) ||
1547 val ==
static_cast<std::int64_t
>(val)) {
Check for complex.
Definition TypeTools.hpp:195
static constexpr bool value
Definition TypeTools.hpp:202
Definition TypeTools.hpp:145
static constexpr bool value
Definition TypeTools.hpp:164
Check for input streamability.
Definition TypeTools.hpp:184
static constexpr bool value
Definition TypeTools.hpp:191
Definition TypeTools.hpp:173
static constexpr bool value
Definition TypeTools.hpp:180
Definition TypeTools.hpp:257
static constexpr bool value
Definition TypeTools.hpp:265
constexpr enabler dummy
An instance to use in EnableIf.
Definition TypeTools.hpp:34
auto to_string(T &&value) -> decltype(std::forward< T >(value))
Convert an object to a string (directly forward if this can become a string)
Definition TypeTools.hpp:270
auto checked_to_string(T &&value) -> decltype(to_string(std::forward< T >(value)))
special template overload
Definition TypeTools.hpp:326
std::vector< std::string > output
Definition StringTools.hpp:354
return false
Definition TypeTools.hpp:812
bool is_separator(const std::string &str)
check if a string is a container segment separator (empty or "%%")
Definition StringTools.hpp:248
bool from_stream(const std::string &istring, T &obj)
Templated operation to get a value from a stream.
Definition TypeTools.hpp:207
constexpr int expected_max_vector_size
Definition StringTools.hpp:43
std::string value_string(const T &value)
get a string as a convertible value for arithmetic types
Definition TypeTools.hpp:340
std::string join(const T &v, std::string delim=",")
Simple function to join a string.
Definition StringTools.hpp:63
bool lexical_assign(const std::string &input, AssignTo &output)
Assign a value through lexical cast operations.
Definition TypeTools.hpp:1107
std::string to_lower(std::string str)
Return a lower case version of a string.
Definition StringTools.hpp:259
enabler
Simple empty scoped class.
Definition TypeTools.hpp:31
bool lexical_cast(const std::string &input, T &output)
Integer conversion.
Definition TypeTools.hpp:883
std::int64_t to_flag_value(std::string val)
Convert a flag into an integer value typically binary flags.
Definition TypeTools.hpp:836
bool integral_conversion(const std::string &input, T &output) noexcept
Convert to a signed integral.
Definition TypeTools.hpp:817
constexpr std::enable_if< I==type_count_base< T >::value, int >::type tuple_type_size()
0 if the index > tuple size
Definition TypeTools.hpp:424
typename make_void< Ts... >::type void_t
A copy of std::void_t from C++17 - same reasoning as enable_if_t, it does not hurt to redefine.
Definition TypeTools.hpp:48
typename std::enable_if< B, T >::type enable_if_t
Definition TypeTools.hpp:42
typename std::conditional< B, T, F >::type conditional_t
A copy of std::conditional_t from C++14 - same reasoning as enable_if_t, it does not hurt to redefine...
Definition TypeTools.hpp:51
std::string type
Definition TypeTools.hpp:77
This can be specialized to override the type deduction for IsMember.
Definition TypeTools.hpp:74
T type
Definition TypeTools.hpp:74
typename std::pointer_traits< T >::element_type type
Definition TypeTools.hpp:90
not a pointer
Definition TypeTools.hpp:87
T type
Definition TypeTools.hpp:87
Definition TypeTools.hpp:95
typename element_type< T >::type::value_type type
Definition TypeTools.hpp:95
Definition TypeTools.hpp:220
Definition TypeTools.hpp:238
Definition TypeTools.hpp:250
typename std::remove_const< typename value_type::first_type >::type first_type
Definition TypeTools.hpp:121
static auto first(Q &&pair_value) -> decltype(std::get< 0 >(std::forward< Q >(pair_value)))
Get the first value (really just the underlying value)
Definition TypeTools.hpp:125
static auto second(Q &&pair_value) -> decltype(std::get< 1 >(std::forward< Q >(pair_value)))
Get the second value (really just the underlying value)
Definition TypeTools.hpp:129
typename T::value_type value_type
Definition TypeTools.hpp:120
typename std::remove_const< typename value_type::second_type >::type second_type
Definition TypeTools.hpp:122
Adaptor for set-like structure: This just wraps a normal container in a few utilities that do almost ...
Definition TypeTools.hpp:98
typename T::value_type value_type
Definition TypeTools.hpp:99
typename std::remove_const< value_type >::type second_type
Definition TypeTools.hpp:101
static auto second(Q &&pair_value) -> decltype(std::forward< Q >(pair_value))
Get the second value (really just the underlying value)
Definition TypeTools.hpp:108
typename std::remove_const< value_type >::type first_type
Definition TypeTools.hpp:100
static auto first(Q &&pair_value) -> decltype(std::forward< Q >(pair_value))
Get the first value (really just the underlying value)
Definition TypeTools.hpp:104
forward declare the subtype_count_min structure
Definition TypeTools.hpp:391
Set of overloads to get the type size of an object.
Definition TypeTools.hpp:388
This will only trigger for actual void type.
Definition TypeTools.hpp:364
static const int value
Definition TypeTools.hpp:364
This will only trigger for actual void type.
Definition TypeTools.hpp:394
static const int value
Definition TypeTools.hpp:394
typename T::value_type type
Definition TypeTools.hpp:360
template to get the underlying value type if it exists or use a default
Definition TypeTools.hpp:356
def type
Definition TypeTools.hpp:356
Check to see if something is bool (fail check by default)
Definition TypeTools.hpp:54
Check to see if something is copyable pointer.
Definition TypeTools.hpp:69
static bool const value
Definition TypeTools.hpp:70
Check to see if something is a shared pointer.
Definition TypeTools.hpp:60
A copy of std::void_t from C++17 (helper for C++11 and C++14)
Definition TypeTools.hpp:45
void type
Definition TypeTools.hpp:45