47template <
bool B,
class T =
void>
using enable_if_t =
typename std::enable_if<B, T>::type;
58template <
bool B,
class T,
class F>
using conditional_t =
typename std::conditional<B, T, F>::type;
61template <
typename T>
struct is_bool : std::false_type {};
64template <>
struct is_bool<bool> : std::true_type {};
70template <
typename T>
struct is_shared_ptr<std::shared_ptr<T>> : std::true_type {};
73template <
typename T>
struct is_shared_ptr<const std::shared_ptr<T>> : std::true_type {};
97 template <
typename TT,
typename SS>
98 static auto test(
int) ->
decltype(lexical_cast(std::declval<const SS &>(), std::declval<TT &>()), std::true_type());
100 template <
typename,
typename>
static auto test(...) -> std::false_type;
119template <
typename T>
struct element_type<T, typename std::enable_if<is_copyable_ptr<T>::value>::type> {
120 using type =
typename std::pointer_traits<T>::element_type;
130template <
typename T,
typename _ =
void>
struct pair_adaptor : std::false_type {
132 using first_type =
typename std::remove_const<value_type>::type;
136 template <
typename Q>
static auto first(Q &&pair_value) ->
decltype(std::forward<Q>(pair_value)) {
137 return std::forward<Q>(pair_value);
140 template <
typename Q>
static auto second(Q &&pair_value) ->
decltype(std::forward<Q>(pair_value)) {
141 return std::forward<Q>(pair_value);
150 conditional_t<false,
void_t<typename T::value_type::first_type, typename T::value_type::second_type>, void>>
153 using first_type =
typename std::remove_const<typename value_type::first_type>::type;
154 using second_type =
typename std::remove_const<typename value_type::second_type>::type;
157 template <
typename Q>
static auto first(Q &&pair_value) ->
decltype(std::get<0>(std::forward<Q>(pair_value))) {
158 return std::get<0>(std::forward<Q>(pair_value));
161 template <
typename Q>
static auto second(Q &&pair_value) ->
decltype(std::get<1>(std::forward<Q>(pair_value))) {
162 return std::get<1>(std::forward<Q>(pair_value));
173#pragma GCC diagnostic push
174#pragma GCC diagnostic ignored "-Wnarrowing"
178 template <
typename TT,
typename CC>
179 static auto test(
int, std::true_type) ->
decltype(
182#ifdef __NVCC_DIAG_PRAGMA_SUPPORT__
183#pragma nv_diag_suppress 2361
185#pragma diag_suppress 2361
188 TT{std::declval<CC>()}
190#ifdef __NVCC_DIAG_PRAGMA_SUPPORT__
191#pragma nv_diag_default 2361
193#pragma diag_default 2361
197 std::is_move_assignable<TT>());
199 template <
typename TT,
typename CC>
static auto test(
int, std::false_type) -> std::false_type;
201 template <
typename,
typename>
static auto test(...) -> std::false_type;
204 static constexpr bool value =
decltype(test<T, C>(0,
typename std::is_constructible<T, C>::type()))
::value;
207#pragma GCC diagnostic pop
214 template <
typename TT,
typename SS>
215 static auto test(
int) ->
decltype(std::declval<SS &>() << std::declval<TT>(), std::true_type());
217 template <
typename,
typename>
static auto test(...) -> std::false_type;
225 template <
typename TT,
typename SS>
226 static auto test(
int) ->
decltype(std::declval<SS &>() >> std::declval<TT &>(), std::true_type());
228 template <
typename,
typename>
static auto test(...) -> std::false_type;
236 template <
typename TT>
237 static auto test(
int) ->
decltype(std::declval<TT>().real(), std::declval<TT>().imag(), std::true_type());
239 template <
typename>
static auto test(...) -> std::false_type;
248 std::istringstream is;
251 return !is.fail() && !is.rdbuf()->in_avail();
269 void_t<typename T::value_type,
270 decltype(std::declval<T>().end()),
271 decltype(std::declval<T>().clear()),
272 decltype(std::declval<T>().insert(std::declval<decltype(std::declval<T>().end())>(),
273 std::declval<const typename T::value_type &>()))>,
274 void>> :
public conditional_t<std::is_constructible<T, std::string>::value ||
275 std::is_constructible<T, std::wstring>::value,
287 conditional_t<false,
void_t<decltype(std::declval<T>().end()), decltype(std::declval<T>().begin())>, void>>
288 :
public std::true_type {};
291template <
typename T,
typename _ =
void>
struct is_wrapper : std::false_type {};
303 static auto test(
int) ->
decltype(std::tuple_size<typename std::decay<SS>::type>
::value, std::true_type{});
304 template <
typename>
static auto test(...) -> std::false_type;
318 typename std::enable_if<!is_tuple_like<T>::value && !is_mutable_container<T>::value &&
319 !std::is_void<T>::value>::type> {
325struct type_count_base<T, typename std::enable_if<is_tuple_like<T>::value && !is_mutable_container<T>::value>::type> {
327 std::tuple_size<typename std::decay<T>::type>
::value};
331template <
typename T>
struct type_count_base<T, typename std::enable_if<is_mutable_container<T>::value>::type> {
337auto to_string(T &&value) ->
decltype(std::forward<T>(value)) {
338 return std::forward<T>(value);
346 return std::string(value);
355 std::stringstream stream;
364 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
371 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
379 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
389 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
392inline std::string
to_string(T &&variable) {
393 auto cval = variable.begin();
394 auto end = variable.end();
398 std::vector<std::string> defaults;
409template <
typename T, std::
size_t I>
410inline typename std::enable_if<I == type_count_base<T>::value, std::string>::type
tuple_value_string(T && );
413template <
typename T, std::
size_t I>
414inline typename std::enable_if<(I < type_count_base<T>::value), std::string>::type
tuple_value_string(T &&value);
418 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
427 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
431 auto tname = std::string(1,
'[') + tuple_value_string<T, 0>(value);
432 tname.push_back(
']');
437template <
typename T, std::
size_t I>
438inline typename std::enable_if<I == type_count_base<T>::value, std::string>::type
tuple_value_string(T && ) {
439 return std::string{};
443template <
typename T, std::
size_t I>
444inline typename std::enable_if<(I < type_count_base<T>::value), std::string>::type
tuple_value_string(T &&value) {
445 auto str = std::string{
to_string(std::get<I>(value))} +
',' + tuple_value_string<T, I + 1>(value);
446 if(str.back() ==
',')
452template <
typename T1,
457 return to_string(std::forward<T>(value));
461template <
typename T1,
466 return std::string{};
471 return std::to_string(value);
476 return std::to_string(
static_cast<typename std::underlying_type<T>::type
>(value));
486template <
typename T,
typename def,
typename Enable =
void>
struct wrapped_type {
491template <
typename T,
typename def>
struct wrapped_type<T, def, typename std::enable_if<is_wrapper<T>::value>::type> {
492 using type =
typename T::value_type;
504template <
typename T,
typename Enable =
void>
struct type_count {
511 typename std::enable_if<!is_wrapper<T>::value && !is_tuple_like<T>::value && !is_complex<T>::value &&
512 !std::is_void<T>::value>::type> {
517template <
typename T>
struct type_count<T, typename std::enable_if<is_complex<T>::value>::type> {
522template <
typename T>
struct type_count<T, typename std::enable_if<is_mutable_container<T>::value>::type> {
529 typename std::enable_if<is_wrapper<T>::value && !is_complex<T>::value && !is_tuple_like<T>::value &&
530 !is_mutable_container<T>::value>::type> {
535template <
typename T, std::
size_t I>
536constexpr typename std::enable_if<I == type_count_base<T>::value,
int>::type
tuple_type_size() {
541template <
typename T, std::
size_t I>
542 constexpr typename std::enable_if < I<type_count_base<T>::value,
int>::type
tuple_type_size() {
543 return subtype_count<typename std::tuple_element<I, T>::type>::value + tuple_type_size<T, I + 1>();
547template <
typename T>
struct type_count<T, typename std::enable_if<is_tuple_like<T>::value>::type> {
548 static constexpr int value{tuple_type_size<T, 0>()};
552template <
typename T>
struct subtype_count {
557template <
typename T,
typename Enable =
void>
struct type_count_min {
558 static const int value{0};
563struct type_count_min<
565 typename std::enable_if<!is_mutable_container<T>::value && !is_tuple_like<T>::value && !is_wrapper<T>::value &&
566 !is_complex<T>::value && !std::is_void<T>::value>::type> {
567 static constexpr int value{type_count<T>::value};
571template <
typename T>
struct type_count_min<T, typename std::enable_if<is_complex<T>::value>::type> {
572 static constexpr int value{1};
577struct type_count_min<
579 typename std::enable_if<is_wrapper<T>::value && !is_complex<T>::value && !is_tuple_like<T>::value>::type> {
580 static constexpr int value{subtype_count_min<typename T::value_type>::value};
584template <
typename T, std::
size_t I>
585constexpr typename std::enable_if<I == type_count_base<T>::value,
int>::type tuple_type_size_min() {
590template <
typename T, std::
size_t I>
591 constexpr typename std::enable_if < I<type_count_base<T>::value,
int>::type tuple_type_size_min() {
592 return subtype_count_min<typename std::tuple_element<I, T>::type>::value + tuple_type_size_min<T, I + 1>();
596template <
typename T>
struct type_count_min<T, typename std::enable_if<is_tuple_like<T>::value>::type> {
597 static constexpr int value{tuple_type_size_min<T, 0>()};
601template <
typename T>
struct subtype_count_min {
602 static constexpr int value{is_mutable_container<T>::value
604 : type_count_min<T>::value};
608template <
typename T,
typename Enable =
void>
struct expected_count {
609 static const int value{0};
614struct expected_count<T,
615 typename std::enable_if<!is_mutable_container<T>::value && !is_wrapper<T>::value &&
616 !std::is_void<T>::value>::type> {
617 static constexpr int value{1};
620template <
typename T>
struct expected_count<T, typename std::enable_if<is_mutable_container<T>::value>::type> {
626struct expected_count<T, typename std::enable_if<!is_mutable_container<T>::value && is_wrapper<T>::value>::type> {
627 static constexpr int value{expected_count<typename T::value_type>::value};
631enum class object_category :
int {
634 unsigned_integral = 4,
638 number_constructible = 12,
639 double_constructible = 14,
640 integer_constructible = 16,
642 string_assignable = 23,
643 string_constructible = 24,
644 wstring_assignable = 25,
645 wstring_constructible = 26,
651 container_value = 80,
658template <
typename T,
typename Enable =
void>
struct classify_object {
659 static constexpr object_category value{object_category::other};
664struct classify_object<
666 typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, char>::value && std::is_signed<T>::value &&
667 !is_bool<T>::value && !std::is_enum<T>::value>::type> {
668 static constexpr object_category value{object_category::integral_value};
673struct classify_object<T,
674 typename std::enable_if<std::is_integral<T>::value && std::is_unsigned<T>::value &&
675 !std::is_same<T, char>::value && !is_bool<T>::value>::type> {
676 static constexpr object_category value{object_category::unsigned_integral};
681struct classify_object<T, typename std::enable_if<std::is_same<T, char>::value && !std::is_enum<T>::value>::type> {
682 static constexpr object_category value{object_category::char_value};
686template <
typename T>
struct classify_object<T, typename std::enable_if<is_bool<T>::value>::type> {
687 static constexpr object_category value{object_category::boolean_value};
691template <
typename T>
struct classify_object<T, typename std::enable_if<std::is_floating_point<T>::value>::type> {
692 static constexpr object_category value{object_category::floating_point};
697#define WIDE_STRING_CHECK \
698 !std::is_assignable<T &, std::wstring>::value && !std::is_constructible<T, std::wstring>::value
699#define STRING_CHECK true
701#define WIDE_STRING_CHECK true
702#define STRING_CHECK !std::is_assignable<T &, std::string>::value && !std::is_constructible<T, std::string>::value
707struct classify_object<
709 typename std::enable_if<!std::is_floating_point<T>::value && !std::is_integral<T>::value && WIDE_STRING_CHECK &&
710 std::is_assignable<T &, std::string>::value>::type> {
711 static constexpr object_category value{object_category::string_assignable};
716struct classify_object<
718 typename std::enable_if<!std::is_floating_point<T>::value && !std::is_integral<T>::value &&
719 !std::is_assignable<T &, std::string>::value && (type_count<T>::value == 1) &&
720 WIDE_STRING_CHECK && std::is_constructible<T, std::string>::value>::type> {
721 static constexpr object_category value{object_category::string_constructible};
726struct classify_object<T,
727 typename std::enable_if<!std::is_floating_point<T>::value && !std::is_integral<T>::value &&
728 STRING_CHECK && std::is_assignable<T &, std::wstring>::value>::type> {
729 static constexpr object_category value{object_category::wstring_assignable};
733struct classify_object<
735 typename std::enable_if<!std::is_floating_point<T>::value && !std::is_integral<T>::value &&
736 !std::is_assignable<T &, std::wstring>::value && (type_count<T>::value == 1) &&
737 STRING_CHECK && std::is_constructible<T, std::wstring>::value>::type> {
738 static constexpr object_category value{object_category::wstring_constructible};
742template <
typename T>
struct classify_object<T, typename std::enable_if<std::is_enum<T>::value>::type> {
743 static constexpr object_category value{object_category::enumeration};
746template <
typename T>
struct classify_object<T, typename std::enable_if<is_complex<T>::value>::type> {
747 static constexpr object_category value{object_category::complex_number};
752template <
typename T>
struct uncommon_type {
753 using type =
typename std::conditional<
754 !std::is_floating_point<T>::value && !std::is_integral<T>::value &&
755 !std::is_assignable<T &, std::string>::value && !std::is_constructible<T, std::string>::value &&
756 !std::is_assignable<T &, std::wstring>::value && !std::is_constructible<T, std::wstring>::value &&
757 !is_complex<T>::value && !is_mutable_container<T>::value && !std::is_enum<T>::value,
759 std::false_type>::type;
760 static constexpr bool value = type::value;
765struct classify_object<T,
766 typename std::enable_if<(!is_mutable_container<T>::value && is_wrapper<T>::value &&
767 !is_tuple_like<T>::value && uncommon_type<T>::value)>::type> {
768 static constexpr object_category value{object_category::wrapper_value};
773struct classify_object<T,
774 typename std::enable_if<uncommon_type<T>::value && type_count<T>::value == 1 &&
775 !is_wrapper<T>::value && is_direct_constructible<T, double>::value &&
776 is_direct_constructible<T, int>::value>::type> {
777 static constexpr object_category value{object_category::number_constructible};
782struct classify_object<T,
783 typename std::enable_if<uncommon_type<T>::value && type_count<T>::value == 1 &&
784 !is_wrapper<T>::value && !is_direct_constructible<T, double>::value &&
785 is_direct_constructible<T, int>::value>::type> {
786 static constexpr object_category value{object_category::integer_constructible};
791struct classify_object<T,
792 typename std::enable_if<uncommon_type<T>::value && type_count<T>::value == 1 &&
793 !is_wrapper<T>::value && is_direct_constructible<T, double>::value &&
794 !is_direct_constructible<T, int>::value>::type> {
795 static constexpr object_category value{object_category::double_constructible};
800struct classify_object<
802 typename std::enable_if<is_tuple_like<T>::value &&
803 ((type_count<T>::value >= 2 && !is_wrapper<T>::value) ||
804 (uncommon_type<T>::value && !is_direct_constructible<T, double>::value &&
805 !is_direct_constructible<T, int>::value) ||
806 (uncommon_type<T>::value && type_count<T>::value >= 2))>::type> {
807 static constexpr object_category value{object_category::tuple_value};
816template <
typename T>
struct classify_object<T, typename std::enable_if<is_mutable_container<T>::value>::type> {
817 static constexpr object_category value{object_category::container_value};
833 enable_if_t<classify_object<T>::value == object_category::integral_value ||
834 classify_object<T>::value == object_category::integer_constructible,
847 enable_if_t<classify_object<T>::value == object_category::floating_point ||
848 classify_object<T>::value == object_category::number_constructible ||
849 classify_object<T>::value == object_category::double_constructible,
878 enable_if_t<classify_object<T>::value >= object_category::string_assignable &&
879 classify_object<T>::value <= object_category::other,
892 enable_if_t<classify_object<T>::value == object_category::container_value ||
893 classify_object<T>::value == object_category::wrapper_value,
902 return type_name<typename std::decay<typename std::tuple_element<0, T>::type>::type>();
906template <
typename T, std::
size_t I>
907inline typename std::enable_if<I == type_count_base<T>::value, std::string>::type tuple_name() {
908 return std::string{};
912template <
typename T, std::
size_t I>
913inline typename std::enable_if<(I < type_count_base<T>::value), std::string>::type tuple_name() {
914 auto str = std::string{type_name<typename std::decay<typename std::tuple_element<I, T>::type>::type>()} +
',' +
915 tuple_name<T, I + 1>();
916 if(str.back() ==
',')
926 auto tname = std::string(1,
'[') + tuple_name<T, 0>();
927 tname.push_back(
']');
934 classify_object<T>::value == object_category::wrapper_value,
937 return type_name<typename T::value_type>();
945 if(input.empty() || input.front() ==
'-') {
950 std::uint64_t output_ll = std::strtoull(input.c_str(), &val, 0);
951 if(errno == ERANGE) {
954 output =
static_cast<T
>(output_ll);
955 if(val == (input.c_str() + input.size()) &&
static_cast<std::uint64_t
>(output) == output_ll) {
959 std::int64_t output_sll = std::strtoll(input.c_str(), &val, 0);
960 if(val == (input.c_str() + input.size())) {
961 output = (output_sll < 0) ? static_cast<T>(0) :
static_cast<T
>(output_sll);
962 return (
static_cast<std::int64_t
>(output) == output_sll);
965 if(input.find_first_of(
"_'") != std::string::npos) {
966 std::string nstring = input;
967 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'_'), nstring.end());
968 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'\''), nstring.end());
971 if(std::isspace(
static_cast<unsigned char>(input.back()))) {
974 if(input.compare(0, 2,
"0o") == 0 || input.compare(0, 2,
"0O") == 0) {
977 output_ll = std::strtoull(input.c_str() + 2, &val, 8);
978 if(errno == ERANGE) {
981 output =
static_cast<T
>(output_ll);
982 return (val == (input.c_str() + input.size()) &&
static_cast<std::uint64_t
>(output) == output_ll);
984 if(input.compare(0, 2,
"0b") == 0 || input.compare(0, 2,
"0B") == 0) {
990 output_ll = std::strtoull(input.c_str() + 2, &val, 2);
991 if(errno == ERANGE) {
994 output =
static_cast<T
>(output_ll);
995 return (val == (input.c_str() + input.size()) &&
static_cast<std::uint64_t
>(output) == output_ll);
1007 char *val =
nullptr;
1009 std::int64_t output_ll = std::strtoll(input.c_str(), &val, 0);
1010 if(errno == ERANGE) {
1013 output =
static_cast<T
>(output_ll);
1014 if(val == (input.c_str() + input.size()) &&
static_cast<std::int64_t
>(output) == output_ll) {
1017 if(input ==
"true") {
1019 output =
static_cast<T
>(1);
1023 if(input.find_first_of(
"_'") != std::string::npos) {
1024 std::string nstring = input;
1025 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'_'), nstring.end());
1026 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'\''), nstring.end());
1029 if(std::isspace(
static_cast<unsigned char>(input.back()))) {
1032 if(input.compare(0, 2,
"0o") == 0 || input.compare(0, 2,
"0O") == 0) {
1035 output_ll = std::strtoll(input.c_str() + 2, &val, 8);
1036 if(errno == ERANGE) {
1039 output =
static_cast<T
>(output_ll);
1040 return (val == (input.c_str() + input.size()) &&
static_cast<std::int64_t
>(output) == output_ll);
1042 if(input.compare(0, 2,
"0b") == 0 || input.compare(0, 2,
"0B") == 0) {
1048 output_ll = std::strtoll(input.c_str() + 2, &val, 2);
1049 if(errno == ERANGE) {
1052 output =
static_cast<T
>(output_ll);
1053 return (val == (input.c_str() + input.size()) &&
static_cast<std::int64_t
>(output) == output_ll);
1061 static const std::string trueString(
"true");
1062 static const std::string falseString(
"false");
1063 if(val == trueString) {
1066 if(val == falseString) {
1070 std::int64_t ret = 0;
1071 if(val.size() == 1) {
1072 if(val[0] >=
'1' && val[0] <=
'9') {
1073 return (
static_cast<std::int64_t
>(val[0]) -
'0');
1093 if(val == trueString || val ==
"on" || val ==
"yes" || val ==
"enable") {
1095 }
else if(val == falseString || val ==
"off" || val ==
"no" || val ==
"disable") {
1098 char *loc_ptr{
nullptr};
1099 ret = std::strtoll(val.c_str(), &loc_ptr, 0);
1100 if(loc_ptr != (val.c_str() + val.size()) && errno == 0) {
1108template <
typename T,
1110 classify_object<T>::value == object_category::unsigned_integral,
1117template <
typename T,
1119bool lexical_cast(
const std::string &input, T &output) {
1120 if(input.size() == 1) {
1121 output =
static_cast<T
>(input[0]);
1128template <
typename T,
1130bool lexical_cast(
const std::string &input, T &output) {
1135 }
else if(errno == ERANGE) {
1136 output = (input[0] !=
'-');
1144template <
typename T,
1146bool lexical_cast(
const std::string &input, T &output) {
1150 char *val =
nullptr;
1151 auto output_ld = std::strtold(input.c_str(), &val);
1152 output =
static_cast<T
>(output_ld);
1153 if(val == (input.c_str() + input.size())) {
1156 while(std::isspace(
static_cast<unsigned char>(*val))) {
1158 if(val == (input.c_str() + input.size())) {
1164 if(input.find_first_of(
"_'") != std::string::npos) {
1165 std::string nstring = input;
1166 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'_'), nstring.end());
1167 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'\''), nstring.end());
1174template <
typename T,
1176bool lexical_cast(
const std::string &input, T &output) {
1180 bool worked =
false;
1181 auto nloc = str1.find_last_of(
"+-");
1182 if(nloc != std::string::npos && nloc > 0) {
1184 str1 = str1.substr(nloc);
1185 if(str1.back() ==
'i' || str1.back() ==
'j')
1189 if(str1.back() ==
'i' || str1.back() ==
'j') {
1206template <
typename T,
1208bool lexical_cast(
const std::string &input, T &output) {
1217bool lexical_cast(
const std::string &input, T &output) {
1226bool lexical_cast(
const std::string &input, T &output) {
1227 output =
widen(input);
1234bool lexical_cast(
const std::string &input, T &output) {
1235 output = T{
widen(input)};
1240template <
typename T,
1242bool lexical_cast(
const std::string &input, T &output) {
1243 typename std::underlying_type<T>::type val;
1247 output =
static_cast<T
>(val);
1252template <
typename T,
1253 enable_if_t<classify_object<T>::value == object_category::wrapper_value &&
1254 std::is_assignable<T &, typename T::value_type>::value,
1256bool lexical_cast(
const std::string &input, T &output) {
1257 typename T::value_type val;
1265template <
typename T,
1266 enable_if_t<classify_object<T>::value == object_category::wrapper_value &&
1267 !std::is_assignable<T &, typename T::value_type>::value && std::is_assignable<T &, T>::value,
1269bool lexical_cast(
const std::string &input, T &output) {
1270 typename T::value_type val;
1282bool lexical_cast(
const std::string &input, T &output) {
1302bool lexical_cast(
const std::string &input, T &output) {
1315bool lexical_cast(
const std::string &input, T &output) {
1325template <
typename T,
1326 enable_if_t<classify_object<T>::value == object_category::other && std::is_assignable<T &, int>::value,
1328bool lexical_cast(
const std::string &input, T &output) {
1332#pragma warning(push)
1333#pragma warning(disable : 4800)
1351template <
typename T,
1352 enable_if_t<classify_object<T>::value == object_category::other && !std::is_assignable<T &, int>::value &&
1355bool lexical_cast(
const std::string &input, T &output) {
1361template <
typename T,
1362 enable_if_t<classify_object<T>::value == object_category::other && !std::is_assignable<T &, int>::value &&
1366 static_assert(!std::is_same<T, T>::value,
1367 "option object type must have a lexical cast overload or streaming input operator(>>) defined, if it "
1368 "is convertible from another type use the add_option<T, XC>(...) with XC being the known type");
1374template <
typename AssignTo,
1376 enable_if_t<std::is_same<AssignTo, ConvertTo>::value &&
1377 (classify_object<AssignTo>::value == object_category::string_assignable ||
1378 classify_object<AssignTo>::value == object_category::string_constructible ||
1379 classify_object<AssignTo>::value == object_category::wstring_assignable ||
1380 classify_object<AssignTo>::value == object_category::wstring_constructible),
1387template <
typename AssignTo,
1390 classify_object<AssignTo>::value != object_category::string_assignable &&
1391 classify_object<AssignTo>::value != object_category::string_constructible &&
1392 classify_object<AssignTo>::value != object_category::wstring_assignable &&
1393 classify_object<AssignTo>::value != object_category::wstring_constructible,
1397 output = AssignTo{};
1405template <
typename AssignTo,
1407 enable_if_t<std::is_same<AssignTo, ConvertTo>::value && !std::is_assignable<AssignTo &, AssignTo>::value &&
1408 classify_object<AssignTo>::value == object_category::wrapper_value,
1412 typename AssignTo::value_type emptyVal{};
1421template <
typename AssignTo,
1423 enable_if_t<std::is_same<AssignTo, ConvertTo>::value && !std::is_assignable<AssignTo &, AssignTo>::value &&
1424 classify_object<AssignTo>::value != object_category::wrapper_value &&
1425 std::is_assignable<AssignTo &, int>::value,
1434#if defined(__clang__)
1436#pragma clang diagnostic push
1437#pragma clang diagnostic ignored "-Wsign-conversion"
1440#if defined(__clang__)
1441#pragma clang diagnostic pop
1449template <
typename AssignTo,
1451 enable_if_t<!std::is_same<AssignTo, ConvertTo>::value && std::is_assignable<AssignTo &, ConvertTo &>::value,
1455 bool parse_result = (!input.empty()) ?
lexical_cast(input, val) :
true;
1459 return parse_result;
1466 enable_if_t<!std::is_same<AssignTo, ConvertTo>::value && !std::is_assignable<AssignTo &, ConvertTo &>::value &&
1467 std::is_move_assignable<AssignTo>::value,
1471 bool parse_result = input.empty() ? true :
lexical_cast(input, val);
1473 output = AssignTo(val);
1475 return parse_result;
1479template <
typename AssignTo,
1481 enable_if_t<classify_object<ConvertTo>::value <= object_category::other &&
1482 classify_object<AssignTo>::value <= object_category::wrapper_value,
1484bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1485 return lexical_assign<AssignTo, ConvertTo>(strings[0], output);
1490template <
typename AssignTo,
1495bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1497 using FirstType =
typename std::remove_const<typename std::tuple_element<0, ConvertTo>::type>::type;
1498 using SecondType =
typename std::tuple_element<1, ConvertTo>::type;
1501 bool retval = lexical_assign<FirstType, FirstType>(strings[0], v1);
1502 retval = retval && lexical_assign<SecondType, SecondType>((strings.size() > 1) ? strings[1] : std::string{}, v2);
1504 output = AssignTo{v1, v2};
1510template <
class AssignTo,
1512 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1515bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1516 output.erase(output.begin(), output.end());
1517 if(strings.empty()) {
1520 if(strings.size() == 1 && strings[0] ==
"{}") {
1523 bool skip_remaining =
false;
1524 if(strings.size() == 2 && strings[0] ==
"{}" &&
is_separator(strings[1])) {
1525 skip_remaining =
true;
1527 for(
const auto &elem : strings) {
1528 typename AssignTo::value_type out;
1529 bool retval = lexical_assign<typename AssignTo::value_type, typename ConvertTo::value_type>(elem, out);
1533 output.insert(output.end(), std::move(out));
1534 if(skip_remaining) {
1538 return (!output.empty());
1543bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output) {
1545 if(strings.size() >= 2 && !strings[1].empty()) {
1548 auto str1 = strings[1];
1549 if(str1.back() ==
'i' || str1.back() ==
'j') {
1554 output = ConvertTo{x, y};
1558 return lexical_assign<AssignTo, ConvertTo>(strings[0], output);
1562template <
class AssignTo,
1564 enable_if_t<is_mutable_container<AssignTo>::value && (expected_count<ConvertTo>::value == 1) &&
1567bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1570 output.reserve(strings.size());
1571 for(
const auto &elem : strings) {
1573 output.emplace_back();
1574 retval = retval && lexical_assign<typename AssignTo::value_type, ConvertTo>(elem, output.back());
1576 return (!output.empty()) && retval;
1582template <
class AssignTo,
1584 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1587bool lexical_conversion(std::vector<std::string> strings, AssignTo &output);
1590template <
class AssignTo,
1592 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1597bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output);
1600template <
class AssignTo,
1606bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output);
1610template <
typename AssignTo,
1612 enable_if_t<!is_tuple_like<AssignTo>::value && !is_mutable_container<AssignTo>::value &&
1613 classify_object<ConvertTo>::value != object_category::wrapper_value &&
1616bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1618 if(strings.size() > 1 || (!strings.empty() && !(strings.front().empty()))) {
1620 auto retval = lexical_conversion<ConvertTo, ConvertTo>(strings, val);
1621 output = AssignTo{val};
1624 output = AssignTo{};
1629template <
class AssignTo,
class ConvertTo, std::
size_t I>
1631tuple_conversion(
const std::vector<std::string> &, AssignTo &) {
1636template <
class AssignTo,
class ConvertTo>
1638tuple_type_conversion(std::vector<std::string> &strings, AssignTo &output) {
1639 auto retval = lexical_assign<AssignTo, ConvertTo>(strings[0], output);
1640 strings.erase(strings.begin());
1645template <
class AssignTo,
class ConvertTo>
1649tuple_type_conversion(std::vector<std::string> &strings, AssignTo &output) {
1650 auto retval = lexical_conversion<AssignTo, ConvertTo>(strings, output);
1656template <
class AssignTo,
class ConvertTo>
1657inline typename std::enable_if<is_mutable_container<ConvertTo>::value ||
1660tuple_type_conversion(std::vector<std::string> &strings, AssignTo &output) {
1662 std::size_t index{subtype_count_min<ConvertTo>::value};
1663 const std::size_t mx_count{subtype_count<ConvertTo>::value};
1664 const std::size_t mx{(std::min)(mx_count, strings.size() - 1)};
1672 bool retval = lexical_conversion<AssignTo, ConvertTo>(
1673 std::vector<std::string>(strings.begin(), strings.begin() +
static_cast<std::ptrdiff_t
>(index)), output);
1674 if(strings.size() > index) {
1675 strings.erase(strings.begin(), strings.begin() +
static_cast<std::ptrdiff_t
>(index) + 1);
1683template <
class AssignTo,
class ConvertTo, std::
size_t I>
1684inline typename std::enable_if<(I < type_count_base<AssignTo>::value),
bool>::type
1685tuple_conversion(std::vector<std::string> strings, AssignTo &output) {
1687 using ConvertToElement =
typename std::
1688 conditional<is_tuple_like<ConvertTo>::value,
typename std::tuple_element<I, ConvertTo>::type, ConvertTo>::type;
1689 if(!strings.empty()) {
1690 retval = retval && tuple_type_conversion<typename std::tuple_element<I, AssignTo>::type, ConvertToElement>(
1691 strings, std::get<I>(output));
1693 retval = retval && tuple_conversion<AssignTo, ConvertTo, I + 1>(std::move(strings), output);
1698template <
class AssignTo,
1700 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1703bool lexical_conversion(std::vector<std::string> strings, AssignTo &output) {
1705 while(!strings.empty()) {
1707 typename std::remove_const<typename std::tuple_element<0, typename ConvertTo::value_type>::type>::type v1;
1708 typename std::tuple_element<1, typename ConvertTo::value_type>::type v2;
1709 bool retval = tuple_type_conversion<decltype(v1), decltype(v1)>(strings, v1);
1710 if(!strings.empty()) {
1711 retval = retval && tuple_type_conversion<decltype(v2), decltype(v2)>(strings, v2);
1714 output.insert(output.end(),
typename AssignTo::value_type{v1, v2});
1719 return (!output.empty());
1723template <
class AssignTo,
1729bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1732 "if the conversion type is defined as a tuple it must be the same size as the type you are converting to");
1733 return tuple_conversion<AssignTo, ConvertTo, 0>(strings, output);
1737template <
class AssignTo,
1739 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1744bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1747 std::vector<std::string> temp;
1749 std::size_t icount{0};
1751 auto ii_max = strings.size();
1752 while(ii < ii_max) {
1753 temp.push_back(strings[ii]);
1756 if(icount == xcm ||
is_separator(temp.back()) || ii == ii_max) {
1757 if(
static_cast<int>(xcm) > type_count_min<ConvertTo>::value &&
is_separator(temp.back())) {
1760 typename AssignTo::value_type temp_out;
1762 lexical_conversion<typename AssignTo::value_type, typename ConvertTo::value_type>(temp, temp_out);
1767 output.insert(output.end(), std::move(temp_out));
1775template <
typename AssignTo,
1777 enable_if_t<classify_object<ConvertTo>::value == object_category::wrapper_value &&
1778 std::is_assignable<ConvertTo &, ConvertTo>::value,
1780bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output) {
1781 if(strings.empty() || strings.front().empty()) {
1782 output = ConvertTo{};
1785 typename ConvertTo::value_type val;
1786 if(lexical_conversion<typename ConvertTo::value_type, typename ConvertTo::value_type>(strings, val)) {
1787 output = ConvertTo{val};
1794template <
typename AssignTo,
1796 enable_if_t<classify_object<ConvertTo>::value == object_category::wrapper_value &&
1797 !std::is_assignable<AssignTo &, ConvertTo>::value,
1799bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output) {
1800 using ConvertType =
typename ConvertTo::value_type;
1801 if(strings.empty() || strings.front().empty()) {
1802 output = ConvertType{};
1806 if(lexical_conversion<typename ConvertTo::value_type, typename ConvertTo::value_type>(strings, val)) {
1814inline std::string sum_string_vector(
const std::vector<std::string> &values) {
1818 for(
const auto &arg : values) {
1824 fail = (errno != 0);
1828 tv =
static_cast<double>(fv);
1833 for(
const auto &arg : values) {
1837 std::ostringstream out;
Definition TypeTools.hpp:96
static constexpr bool value
Definition TypeTools.hpp:103
Check for complex.
Definition TypeTools.hpp:235
static constexpr bool value
Definition TypeTools.hpp:242
Definition TypeTools.hpp:177
static constexpr bool value
Definition TypeTools.hpp:204
Check for input streamability.
Definition TypeTools.hpp:224
static constexpr bool value
Definition TypeTools.hpp:231
Definition TypeTools.hpp:213
static constexpr bool value
Definition TypeTools.hpp:220
Definition TypeTools.hpp:299
static constexpr bool value
Definition TypeTools.hpp:307
constexpr enabler dummy
An instance to use in EnableIf.
Definition TypeTools.hpp:39
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:337
auto checked_to_string(T &&value) -> decltype(to_string(std::forward< T >(value)))
special template overload
Definition TypeTools.hpp:456
std::enable_if< I==type_count_base< T >::value, std::string >::type tuple_value_string(T &&)
Convert a tuple like object to a string.
Definition TypeTools.hpp:438
bool is_separator(const std::string &str)
check if a string is a container segment separator (empty or "%%")
Definition StringTools.hpp:172
std::string trim_copy(const std::string &str)
Make a copy of the string and then trim it.
Definition StringTools.hpp:122
bool from_stream(const std::string &istring, T &obj)
Templated operation to get a value from a stream.
Definition TypeTools.hpp:247
constexpr int expected_max_vector_size
Definition StringTools.hpp:47
std::string value_string(const T &value)
get a string as a convertible value for arithmetic types
Definition TypeTools.hpp:470
std::string join(const T &v, std::string delim=",")
Simple function to join a string.
Definition StringTools.hpp:53
bool lexical_assign(const std::string &input, AssignTo &output)
Assign a value through lexical cast operations.
Definition TypeTools.hpp:1382
std::int64_t to_flag_value(std::string val) noexcept
Convert a flag into an integer value typically binary flags sets errno to nonzero if conversion faile...
Definition TypeTools.hpp:1060
constexpr std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size() { return subtype_count< typename std::tuple_element< I, T >::type >::value+tuple_type_size< T, I+1 >();}template< typename T > struct type_count< T, typename std::enable_if< is_tuple_like< T >::value >::type > { static constexpr int value{tuple_type_size< T, 0 >()};};template< typename T > struct subtype_count { static constexpr int value{is_mutable_container< T >::value ? expected_max_vector_size :type_count< T >::value};};template< typename T, typename Enable=void > struct type_count_min { static const int value{0};};template< typename T >struct type_count_min< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_tuple_like< T >::value &&!is_wrapper< T >::value &&!is_complex< T >::value &&!std::is_void< T >::value >::type > { static constexpr int value{type_count< T >::value};};template< typename T > struct type_count_min< T, typename std::enable_if< is_complex< T >::value >::type > { static constexpr int value{1};};template< typename T >struct type_count_min< T, typename std::enable_if< is_wrapper< T >::value &&!is_complex< T >::value &&!is_tuple_like< T >::value >::type > { static constexpr int value{subtype_count_min< typename T::value_type >::value};};template< typename T, std::size_t I >constexpr typename std::enable_if< I==type_count_base< T >::value, int >::type tuple_type_size_min() { return 0;}template< typename T, std::size_t I > constexpr typename std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size_min() { return subtype_count_min< typename std::tuple_element< I, T >::type >::value+tuple_type_size_min< T, I+1 >();}template< typename T > struct type_count_min< T, typename std::enable_if< is_tuple_like< T >::value >::type > { static constexpr int value{tuple_type_size_min< T, 0 >()};};template< typename T > struct subtype_count_min { static constexpr int value{is_mutable_container< T >::value ?((type_count< T >::value< expected_max_vector_size) ? type_count< T >::value :0) :type_count_min< T >::value};};template< typename T, typename Enable=void > struct expected_count { static const int value{0};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_wrapper< T >::value &&!std::is_void< T >::value >::type > { static constexpr int value{1};};template< typename T > struct expected_count< T, typename std::enable_if< is_mutable_container< T >::value >::type > { static constexpr int value{expected_max_vector_size};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&is_wrapper< T >::value >::type > { static constexpr int value{expected_count< typename T::value_type >::value};};enum class object_category :int { char_value=1, integral_value=2, unsigned_integral=4, enumeration=6, boolean_value=8, floating_point=10, number_constructible=12, double_constructible=14, integer_constructible=16, string_assignable=23, string_constructible=24, wstring_assignable=25, wstring_constructible=26, other=45, wrapper_value=50, complex_number=60, tuple_value=70, container_value=80,};template< typename T, typename Enable=void > struct classify_object { static constexpr object_category value{object_category::other};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, char >::value &&std::is_signed< T >::value &&!is_bool< T >::value &&!std::is_enum< T >::value >::type > { static constexpr object_category value{object_category::integral_value};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&std::is_unsigned< T >::value &&!std::is_same< T, char >::value &&!is_bool< T >::value >::type > { static constexpr object_category value{object_category::unsigned_integral};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_same< T, char >::value &&!std::is_enum< T >::value >::type > { static constexpr object_category value{object_category::char_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_bool< T >::value >::type > { static constexpr object_category value{object_category::boolean_value};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_floating_point< T >::value >::type > { static constexpr object_category value{object_category::floating_point};};#define WIDE_STRING_CHECK #define STRING_CHECK template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&WIDE_STRING_CHECK &&std::is_assignable< T &, std::string >::value >::type > { static constexpr object_category value{object_category::string_assignable};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&(type_count< T >::value==1) &&WIDE_STRING_CHECK &&std::is_constructible< T, std::string >::value >::type > { static constexpr object_category value{object_category::string_constructible};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&STRING_CHECK &&std::is_assignable< T &, std::wstring >::value >::type > { static constexpr object_category value{object_category::wstring_assignable};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::wstring >::value &&(type_count< T >::value==1) &&STRING_CHECK &&std::is_constructible< T, std::wstring >::value >::type > { static constexpr object_category value{object_category::wstring_constructible};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_enum< T >::value >::type > { static constexpr object_category value{object_category::enumeration};};template< typename T > struct classify_object< T, typename std::enable_if< is_complex< T >::value >::type > { static constexpr object_category value{object_category::complex_number};};template< typename T > struct uncommon_type { using type=typename std::conditional< !std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&!std::is_constructible< T, std::string >::value &&!std::is_assignable< T &, std::wstring >::value &&!std::is_constructible< T, std::wstring >::value &&!is_complex< T >::value &&!is_mutable_container< T >::value &&!std::is_enum< T >::value, std::true_type, std::false_type >::type;static constexpr bool value=type::value;};template< typename T >struct classify_object< T, typename std::enable_if<(!is_mutable_container< T >::value &&is_wrapper< T >::value &&!is_tuple_like< T >::value &&uncommon_type< T >::value)>::type > { static constexpr object_category value{object_category::wrapper_value};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type > { static constexpr object_category value{object_category::number_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&!is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type > { static constexpr object_category value{object_category::integer_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value >::type > { static constexpr object_category value{object_category::double_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< is_tuple_like< T >::value &&((type_count< T >::value >=2 &&!is_wrapper< T >::value)||(uncommon_type< T >::value &&!is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value)||(uncommon_type< T >::value &&type_count< T >::value >=2))>::type > { static constexpr object_category value{object_category::tuple_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_mutable_container< T >::value >::type > { static constexpr object_category value{object_category::container_value};};template< typename T, enable_if_t< classify_object< T >::value==object_category::char_value, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "CHAR";}template< typename T, enable_if_t< classify_object< T >::value==object_category::integral_value||classify_object< T >::value==object_category::integer_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "INT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::unsigned_integral, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "UINT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::floating_point||classify_object< T >::value==object_category::number_constructible||classify_object< T >::value==object_category::double_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "FLOAT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::enumeration, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "ENUM";}template< typename T, enable_if_t< classify_object< T >::value==object_category::boolean_value, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "BOOLEAN";}template< typename T, enable_if_t< classify_object< T >::value==object_category::complex_number, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "COMPLEX";}template< typename T, enable_if_t< classify_object< T >::value >=object_category::string_assignable &&classify_object< T >::value<=object_category::other, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "TEXT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::container_value||classify_object< T >::value==object_category::wrapper_value, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value==1, detail::enabler >=detail::dummy >inline std::string type_name() { return type_name< typename std::decay< typename std::tuple_element< 0, T >::type >::type >();}template< typename T, std::size_t I >inline typename std::enable_if< I==type_count_base< T >::value, std::string >::type tuple_name() { return std::string{};}template< typename T, std::size_t I >inline typename std::enable_if<(I< type_count_base< T >::value), std::string >::type tuple_name() { auto str=std::string{type_name< typename std::decay< typename std::tuple_element< I, T >::type >::type >()}+','+tuple_name< T, I+1 >();if(str.back()==',') str.pop_back();return str;}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler > > std::string type_name()
Recursively generate the tuple type name.
Definition TypeTools.hpp:925
std::string to_lower(std::string str)
Return a lower case version of a string.
Definition StringTools.hpp:183
enabler
Simple empty scoped class.
Definition TypeTools.hpp:36
bool lexical_cast(const std::string &input, T &output)
Integer conversion.
Definition TypeTools.hpp:1112
bool integral_conversion(const std::string &input, T &output) noexcept
Convert to an unsigned integral.
Definition TypeTools.hpp:944
constexpr std::enable_if< I==type_count_base< T >::value, int >::type tuple_type_size()
0 if the index > tuple size
Definition TypeTools.hpp:536
typename std::enable_if< B, T >::type enable_if_t
Definition TypeTools.hpp:47
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:58
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:55
CLI11_INLINE std::wstring widen(const std::string &str)
Convert a narrow string to a wide string.
std::string type
Definition TypeTools.hpp:87
This can be specialized to override the type deduction for IsMember.
Definition TypeTools.hpp:81
T type
Definition TypeTools.hpp:82
typename std::pointer_traits< T >::element_type type
Definition TypeTools.hpp:120
not a pointer
Definition TypeTools.hpp:115
T type
Definition TypeTools.hpp:116
Definition TypeTools.hpp:125
typename element_type< T >::type::value_type type
Definition TypeTools.hpp:126
Definition TypeTools.hpp:260
Definition TypeTools.hpp:280
Definition TypeTools.hpp:291
typename std::remove_const< typename value_type::first_type >::type first_type
Definition TypeTools.hpp:153
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:157
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:161
typename T::value_type value_type
Definition TypeTools.hpp:152
typename std::remove_const< typename value_type::second_type >::type second_type
Definition TypeTools.hpp:154
Adaptor for set-like structure: This just wraps a normal container in a few utilities that do almost ...
Definition TypeTools.hpp:130
typename T::value_type value_type
Definition TypeTools.hpp:131
typename std::remove_const< value_type >::type second_type
Definition TypeTools.hpp:133
static auto second(Q &&pair_value) -> decltype(std::forward< Q >(pair_value))
Get the second value (really just the underlying value)
Definition TypeTools.hpp:140
typename std::remove_const< value_type >::type first_type
Definition TypeTools.hpp:132
static auto first(Q &&pair_value) -> decltype(std::forward< Q >(pair_value))
Get the first value (really just the underlying value)
Definition TypeTools.hpp:136
forward declare the subtype_count_min structure
Definition TypeTools.hpp:501
Set of overloads to get the type size of an object.
Definition TypeTools.hpp:498
This will only trigger for actual void type.
Definition TypeTools.hpp:311
static const int value
Definition TypeTools.hpp:312
This will only trigger for actual void type.
Definition TypeTools.hpp:504
static const int value
Definition TypeTools.hpp:505
typename T::value_type type
Definition TypeTools.hpp:492
template to get the underlying value type if it exists or use a default
Definition TypeTools.hpp:486
def type
Definition TypeTools.hpp:487
Check to see if something is bool (fail check by default)
Definition TypeTools.hpp:61
Check to see if something is copyable pointer.
Definition TypeTools.hpp:76
static bool const value
Definition TypeTools.hpp:77
Check to see if something is a shared pointer.
Definition TypeTools.hpp:67
A copy of std::void_t from C++17 (helper for C++11 and C++14)
Definition TypeTools.hpp:50
void type
Definition TypeTools.hpp:51