24#include "Encoding.hpp"
25#include "StringTools.hpp"
39constexpr enabler dummy = {};
47template <
bool B,
class T =
void>
using enable_if_t =
typename std::enable_if<B, T>::type;
55template <
typename... Ts>
using void_t =
typename make_void<Ts...>::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 {};
87 using type = std::string;
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;
103 static constexpr bool value =
decltype(test<T, S>(0))::value;
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 {
131 using value_type =
typename T::value_type;
132 using first_type =
typename std::remove_const<value_type>::type;
133 using second_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>>
152 using value_type =
typename T::value_type;
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;
220 static constexpr bool value =
decltype(test<T, S>(0))::value;
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;
231 static constexpr bool value =
decltype(test<T, S>(0))::value;
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;
242 static constexpr bool value =
decltype(test<T>(0))::value;
246template <typename T, enable_if_t<is_istreamable<T>::value, detail::enabler> = detail::dummy>
247bool from_stream(
const std::string &istring, T &obj) {
248 std::istringstream is;
251 return !is.fail() && !is.rdbuf()->in_avail();
254template <typename T, enable_if_t<!is_istreamable<T>::value, detail::enabler> = detail::dummy>
255bool from_stream(
const std::string & , T & ) {
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 {};
295struct is_wrapper<T, conditional_t<false, void_t<typename T::value_type>, void>> :
public std::true_type {};
299 template <
typename SS>
302 static auto test(
int) ->
decltype(std::tuple_size<typename std::decay<SS>::type>::value, std::true_type{});
303 template <
typename>
static auto test(...) -> std::false_type;
306 static constexpr bool value =
decltype(test<S>(0))::value;
311 static const int value{0};
317 typename std::enable_if<!is_tuple_like<T>::value && !is_mutable_container<T>::value &&
318 !std::is_void<T>::value>::type> {
319 static constexpr int value{1};
324struct type_count_base<T, typename std::enable_if<is_tuple_like<T>::value && !is_mutable_container<T>::value>::type> {
325 static constexpr int value{
326 std::tuple_size<typename std::decay<T>::type>::value};
330template <
typename T>
struct type_count_base<T, typename std::enable_if<is_mutable_container<T>::value>::type> {
335template <typename T, enable_if_t<std::is_convertible<T, std::string>::value, detail::enabler> = detail::dummy>
336auto to_string(T &&value) ->
decltype(std::forward<T>(value)) {
337 return std::forward<T>(value);
342 enable_if_t<std::is_constructible<std::string, T>::value && !std::is_convertible<T, std::string>::value,
343 detail::enabler> = detail::dummy>
344std::string to_string(T &&value) {
345 return std::string(value);
350 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
351 is_ostreamable<T>::value,
352 detail::enabler> = detail::dummy>
353std::string to_string(T &&value) {
354 std::stringstream stream;
363 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
364 !is_ostreamable<T>::value && is_tuple_like<T>::value && type_count_base<T>::value == 1,
365 detail::enabler> = detail::dummy>
366inline std::string to_string(T &&value);
370 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
371 !is_ostreamable<T>::value && is_tuple_like<T>::value && type_count_base<T>::value >= 2,
372 detail::enabler> = detail::dummy>
373inline std::string to_string(T &&value);
378 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
379 !is_ostreamable<T>::value && !is_readable_container<typename std::remove_const<T>::type>::value &&
380 !is_tuple_like<T>::value,
381 detail::enabler> = detail::dummy>
382inline std::string to_string(T &&) {
388 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
389 !is_ostreamable<T>::value && is_readable_container<T>::value,
390 detail::enabler> = detail::dummy>
391inline std::string to_string(T &&variable) {
392 auto cval = variable.begin();
393 auto end = variable.end();
397 std::vector<std::string> defaults;
399 defaults.emplace_back(CLI::detail::to_string(*cval));
402 return {
"[" + detail::join(defaults) +
"]"};
408template <
typename T, std::
size_t I>
409inline typename std::enable_if<I == type_count_base<T>::value, std::string>::type tuple_value_string(T && );
412template <
typename T, std::
size_t I>
413inline typename std::enable_if<(I < type_count_base<T>::value), std::string>::type tuple_value_string(T &&value);
417 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
418 !is_ostreamable<T>::value && is_tuple_like<T>::value && type_count_base<T>::value == 1,
420inline std::string to_string(T &&value) {
421 return to_string(std::get<0>(value));
426 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
427 !is_ostreamable<T>::value && is_tuple_like<T>::value && type_count_base<T>::value >= 2,
429inline std::string to_string(T &&value) {
430 auto tname = std::string(1,
'[') + tuple_value_string<T, 0>(value);
431 tname.push_back(
']');
436template <
typename T, std::
size_t I>
437inline typename std::enable_if<I == type_count_base<T>::value, std::string>::type tuple_value_string(T && ) {
438 return std::string{};
442template <
typename T, std::
size_t I>
443inline typename std::enable_if<(I < type_count_base<T>::value), std::string>::type tuple_value_string(T &&value) {
444 auto str = std::string{to_string(std::get<I>(value))} +
',' + tuple_value_string<T, I + 1>(value);
445 if(str.back() ==
',')
451template <
typename T1,
454 enable_if_t<std::is_same<T1, T2>::value, detail::enabler> = detail::dummy>
455auto checked_to_string(T &&value) ->
decltype(to_string(std::forward<T>(value))) {
456 return to_string(std::forward<T>(value));
460template <
typename T1,
463 enable_if_t<!std::is_same<T1, T2>::value, detail::enabler> = detail::dummy>
464std::string checked_to_string(T &&) {
465 return std::string{};
468template <typename T, enable_if_t<std::is_arithmetic<T>::value, detail::enabler> = detail::dummy>
469std::string value_string(
const T &value) {
470 return std::to_string(value);
473template <typename T, enable_if_t<std::is_enum<T>::value, detail::enabler> = detail::dummy>
474std::string value_string(
const T &value) {
475 return std::to_string(
static_cast<typename std::underlying_type<T>::type
>(value));
479 enable_if_t<!std::is_enum<T>::value && !std::is_arithmetic<T>::value, detail::enabler> = detail::dummy>
480auto value_string(
const T &value) ->
decltype(to_string(value)) {
481 return to_string(value);
485template <
typename T,
typename def,
typename Enable =
void>
struct wrapped_type {
490template <
typename T,
typename def>
struct wrapped_type<T, def, typename std::enable_if<is_wrapper<T>::value>::type> {
491 using type =
typename T::value_type;
503template <
typename T,
typename Enable =
void>
struct type_count {
504 static const int value{0};
510 typename std::enable_if<!is_wrapper<T>::value && !is_tuple_like<T>::value && !is_complex<T>::value &&
511 !std::is_void<T>::value>::type> {
512 static constexpr int value{1};
516template <
typename T>
struct type_count<T, typename std::enable_if<is_complex<T>::value>::type> {
517 static constexpr int value{2};
521template <
typename T>
struct type_count<T, typename std::enable_if<is_mutable_container<T>::value>::type> {
528 typename std::enable_if<is_wrapper<T>::value && !is_complex<T>::value && !is_tuple_like<T>::value &&
529 !is_mutable_container<T>::value>::type> {
534template <
typename T, std::
size_t I>
535constexpr typename std::enable_if<I == type_count_base<T>::value,
int>::type tuple_type_size() {
540template <
typename T, std::
size_t I>
541 constexpr typename std::enable_if < I<type_count_base<T>::value,
int>::type tuple_type_size() {
542 return subtype_count<typename std::tuple_element<I, T>::type>::value + tuple_type_size<T, I + 1>();
546template <
typename T>
struct type_count<T, typename std::enable_if<is_tuple_like<T>::value>::type> {
547 static constexpr int value{tuple_type_size<T, 0>()};
551template <
typename T>
struct subtype_count {
552 static constexpr int value{is_mutable_container<T>::value ? expected_max_vector_size : type_count<T>::value};
556template <
typename T,
typename Enable =
void>
struct type_count_min {
557 static const int value{0};
562struct type_count_min<
564 typename std::enable_if<!is_mutable_container<T>::value && !is_tuple_like<T>::value && !is_wrapper<T>::value &&
565 !is_complex<T>::value && !std::is_void<T>::value>::type> {
566 static constexpr int value{type_count<T>::value};
570template <
typename T>
struct type_count_min<T, typename std::enable_if<is_complex<T>::value>::type> {
571 static constexpr int value{1};
576struct type_count_min<
578 typename std::enable_if<is_wrapper<T>::value && !is_complex<T>::value && !is_tuple_like<T>::value>::type> {
579 static constexpr int value{subtype_count_min<typename T::value_type>::value};
583template <
typename T, std::
size_t I>
584constexpr typename std::enable_if<I == type_count_base<T>::value,
int>::type tuple_type_size_min() {
589template <
typename T, std::
size_t I>
590 constexpr typename std::enable_if < I<type_count_base<T>::value,
int>::type tuple_type_size_min() {
591 return subtype_count_min<typename std::tuple_element<I, T>::type>::value + tuple_type_size_min<T, I + 1>();
595template <
typename T>
struct type_count_min<T, typename std::enable_if<is_tuple_like<T>::value>::type> {
596 static constexpr int value{tuple_type_size_min<T, 0>()};
600template <
typename T>
struct subtype_count_min {
601 static constexpr int value{is_mutable_container<T>::value
602 ? ((type_count<T>::value < expected_max_vector_size) ? type_count<T>::value : 0)
603 : type_count_min<T>::value};
607template <
typename T,
typename Enable =
void>
struct expected_count {
608 static const int value{0};
613struct expected_count<T,
614 typename std::enable_if<!is_mutable_container<T>::value && !is_wrapper<T>::value &&
615 !std::is_void<T>::value>::type> {
616 static constexpr int value{1};
619template <
typename T>
struct expected_count<T, typename std::enable_if<is_mutable_container<T>::value>::type> {
620 static constexpr int value{expected_max_vector_size};
625struct expected_count<T, typename std::enable_if<!is_mutable_container<T>::value && is_wrapper<T>::value>::type> {
626 static constexpr int value{expected_count<typename T::value_type>::value};
630enum class object_category :
int {
633 unsigned_integral = 4,
637 number_constructible = 12,
638 double_constructible = 14,
639 integer_constructible = 16,
641 string_assignable = 23,
642 string_constructible = 24,
643 wstring_assignable = 25,
644 wstring_constructible = 26,
650 container_value = 80,
657template <
typename T,
typename Enable =
void>
struct classify_object {
658 static constexpr object_category value{object_category::other};
663struct classify_object<
665 typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, char>::value && std::is_signed<T>::value &&
666 !is_bool<T>::value && !std::is_enum<T>::value>::type> {
667 static constexpr object_category value{object_category::integral_value};
672struct classify_object<T,
673 typename std::enable_if<std::is_integral<T>::value && std::is_unsigned<T>::value &&
674 !std::is_same<T, char>::value && !is_bool<T>::value>::type> {
675 static constexpr object_category value{object_category::unsigned_integral};
680struct classify_object<T, typename std::enable_if<std::is_same<T, char>::value && !std::is_enum<T>::value>::type> {
681 static constexpr object_category value{object_category::char_value};
685template <
typename T>
struct classify_object<T, typename std::enable_if<is_bool<T>::value>::type> {
686 static constexpr object_category value{object_category::boolean_value};
690template <
typename T>
struct classify_object<T, typename std::enable_if<std::is_floating_point<T>::value>::type> {
691 static constexpr object_category value{object_category::floating_point};
696#define WIDE_STRING_CHECK \
697 !std::is_assignable<T &, std::wstring>::value && !std::is_constructible<T, std::wstring>::value
698#define STRING_CHECK true
700#define WIDE_STRING_CHECK true
701#define STRING_CHECK !std::is_assignable<T &, std::string>::value && !std::is_constructible<T, std::string>::value
706struct classify_object<
708 typename std::enable_if<!std::is_floating_point<T>::value && !std::is_integral<T>::value && WIDE_STRING_CHECK &&
709 std::is_assignable<T &, std::string>::value>::type> {
710 static constexpr object_category value{object_category::string_assignable};
715struct classify_object<
717 typename std::enable_if<!std::is_floating_point<T>::value && !std::is_integral<T>::value &&
718 !std::is_assignable<T &, std::string>::value && (type_count<T>::value == 1) &&
719 WIDE_STRING_CHECK && std::is_constructible<T, std::string>::value>::type> {
720 static constexpr object_category value{object_category::string_constructible};
725struct classify_object<T,
726 typename std::enable_if<!std::is_floating_point<T>::value && !std::is_integral<T>::value &&
727 STRING_CHECK && std::is_assignable<T &, std::wstring>::value>::type> {
728 static constexpr object_category value{object_category::wstring_assignable};
732struct classify_object<
734 typename std::enable_if<!std::is_floating_point<T>::value && !std::is_integral<T>::value &&
735 !std::is_assignable<T &, std::wstring>::value && (type_count<T>::value == 1) &&
736 STRING_CHECK && std::is_constructible<T, std::wstring>::value>::type> {
737 static constexpr object_category value{object_category::wstring_constructible};
741template <
typename T>
struct classify_object<T, typename std::enable_if<std::is_enum<T>::value>::type> {
742 static constexpr object_category value{object_category::enumeration};
745template <
typename T>
struct classify_object<T, typename std::enable_if<is_complex<T>::value>::type> {
746 static constexpr object_category value{object_category::complex_number};
751template <
typename T>
struct uncommon_type {
752 using type =
typename std::conditional<
753 !std::is_floating_point<T>::value && !std::is_integral<T>::value &&
754 !std::is_assignable<T &, std::string>::value && !std::is_constructible<T, std::string>::value &&
755 !std::is_assignable<T &, std::wstring>::value && !std::is_constructible<T, std::wstring>::value &&
756 !is_complex<T>::value && !is_mutable_container<T>::value && !std::is_enum<T>::value,
758 std::false_type>::type;
759 static constexpr bool value = type::value;
764struct classify_object<T,
765 typename std::enable_if<(!is_mutable_container<T>::value && is_wrapper<T>::value &&
766 !is_tuple_like<T>::value && uncommon_type<T>::value)>::type> {
767 static constexpr object_category value{object_category::wrapper_value};
772struct classify_object<T,
773 typename std::enable_if<uncommon_type<T>::value && type_count<T>::value == 1 &&
774 !is_wrapper<T>::value && is_direct_constructible<T, double>::value &&
775 is_direct_constructible<T, int>::value>::type> {
776 static constexpr object_category value{object_category::number_constructible};
781struct classify_object<T,
782 typename std::enable_if<uncommon_type<T>::value && type_count<T>::value == 1 &&
783 !is_wrapper<T>::value && !is_direct_constructible<T, double>::value &&
784 is_direct_constructible<T, int>::value>::type> {
785 static constexpr object_category value{object_category::integer_constructible};
790struct classify_object<T,
791 typename std::enable_if<uncommon_type<T>::value && type_count<T>::value == 1 &&
792 !is_wrapper<T>::value && is_direct_constructible<T, double>::value &&
793 !is_direct_constructible<T, int>::value>::type> {
794 static constexpr object_category value{object_category::double_constructible};
799struct classify_object<
801 typename std::enable_if<is_tuple_like<T>::value &&
802 ((type_count<T>::value >= 2 && !is_wrapper<T>::value) ||
803 (uncommon_type<T>::value && !is_direct_constructible<T, double>::value &&
804 !is_direct_constructible<T, int>::value) ||
805 (uncommon_type<T>::value && type_count<T>::value >= 2))>::type> {
806 static constexpr object_category value{object_category::tuple_value};
815template <
typename T>
struct classify_object<T, typename std::enable_if<is_mutable_container<T>::value>::type> {
816 static constexpr object_category value{object_category::container_value};
826 enable_if_t<classify_object<T>::value == object_category::char_value, detail::enabler> = detail::dummy>
827constexpr const char *type_name() {
832 enable_if_t<classify_object<T>::value == object_category::integral_value ||
833 classify_object<T>::value == object_category::integer_constructible,
834 detail::enabler> = detail::dummy>
835constexpr const char *type_name() {
840 enable_if_t<classify_object<T>::value == object_category::unsigned_integral, detail::enabler> = detail::dummy>
841constexpr const char *type_name() {
846 enable_if_t<classify_object<T>::value == object_category::floating_point ||
847 classify_object<T>::value == object_category::number_constructible ||
848 classify_object<T>::value == object_category::double_constructible,
849 detail::enabler> = detail::dummy>
850constexpr const char *type_name() {
856 enable_if_t<classify_object<T>::value == object_category::enumeration, detail::enabler> = detail::dummy>
857constexpr const char *type_name() {
863 enable_if_t<classify_object<T>::value == object_category::boolean_value, detail::enabler> = detail::dummy>
864constexpr const char *type_name() {
870 enable_if_t<classify_object<T>::value == object_category::complex_number, detail::enabler> = detail::dummy>
871constexpr const char *type_name() {
877 enable_if_t<classify_object<T>::value >= object_category::string_assignable &&
878 classify_object<T>::value <= object_category::other,
879 detail::enabler> = detail::dummy>
880constexpr const char *type_name() {
885 enable_if_t<classify_object<T>::value == object_category::tuple_value && type_count_base<T>::value >= 2,
886 detail::enabler> = detail::dummy>
887std::string type_name();
891 enable_if_t<classify_object<T>::value == object_category::container_value ||
892 classify_object<T>::value == object_category::wrapper_value,
893 detail::enabler> = detail::dummy>
894std::string type_name();
898 enable_if_t<classify_object<T>::value == object_category::tuple_value && type_count_base<T>::value == 1,
899 detail::enabler> = detail::dummy>
900inline std::string type_name() {
901 return type_name<typename std::decay<typename std::tuple_element<0, T>::type>::type>();
905template <
typename T, std::
size_t I>
906inline typename std::enable_if<I == type_count_base<T>::value, std::string>::type tuple_name() {
907 return std::string{};
911template <
typename T, std::
size_t I>
912inline typename std::enable_if<(I < type_count_base<T>::value), std::string>::type tuple_name() {
913 auto str = std::string{type_name<typename std::decay<typename std::tuple_element<I, T>::type>::type>()} +
',' +
914 tuple_name<T, I + 1>();
915 if(str.back() ==
',')
922 enable_if_t<classify_object<T>::value == object_category::tuple_value && type_count_base<T>::value >= 2,
924inline std::string type_name() {
925 auto tname = std::string(1,
'[') + tuple_name<T, 0>();
926 tname.push_back(
']');
932 enable_if_t<classify_object<T>::value == object_category::container_value ||
933 classify_object<T>::value == object_category::wrapper_value,
935inline std::string type_name() {
936 return type_name<typename T::value_type>();
942template <typename T, enable_if_t<std::is_unsigned<T>::value, detail::enabler> = detail::dummy>
943bool integral_conversion(
const std::string &input, T &output)
noexcept {
944 if(input.empty() || input.front() ==
'-') {
949 std::uint64_t output_ll = std::strtoull(input.c_str(), &val, 0);
950 if(errno == ERANGE) {
953 output =
static_cast<T
>(output_ll);
954 if(val == (input.c_str() + input.size()) &&
static_cast<std::uint64_t
>(output) == output_ll) {
958 std::int64_t output_sll = std::strtoll(input.c_str(), &val, 0);
959 if(val == (input.c_str() + input.size())) {
960 output = (output_sll < 0) ? static_cast<T>(0) : static_cast<T>(output_sll);
961 return (
static_cast<std::int64_t
>(output) == output_sll);
964 if(input.find_first_of(
"_'") != std::string::npos) {
965 std::string nstring = input;
966 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'_'), nstring.end());
967 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'\''), nstring.end());
968 return integral_conversion(nstring, output);
970 if(input.compare(0, 2,
"0o") == 0 || input.compare(0, 2,
"0O") == 0) {
973 output_ll = std::strtoull(input.c_str() + 2, &val, 8);
974 if(errno == ERANGE) {
977 output =
static_cast<T
>(output_ll);
978 return (val == (input.c_str() + input.size()) &&
static_cast<std::uint64_t
>(output) == output_ll);
980 if(input.compare(0, 2,
"0b") == 0 || input.compare(0, 2,
"0B") == 0) {
986 output_ll = std::strtoull(input.c_str() + 2, &val, 2);
987 if(errno == ERANGE) {
990 output =
static_cast<T
>(output_ll);
991 return (val == (input.c_str() + input.size()) &&
static_cast<std::uint64_t
>(output) == output_ll);
998template <typename T, enable_if_t<std::is_signed<T>::value, detail::enabler> = detail::dummy>
999bool integral_conversion(
const std::string &input, T &output)
noexcept {
1003 char *val =
nullptr;
1005 std::int64_t output_ll = std::strtoll(input.c_str(), &val, 0);
1006 if(errno == ERANGE) {
1009 output =
static_cast<T
>(output_ll);
1010 if(val == (input.c_str() + input.size()) &&
static_cast<std::int64_t
>(output) == output_ll) {
1013 if(input ==
"true") {
1015 output =
static_cast<T
>(1);
1019 if(input.find_first_of(
"_'") != std::string::npos) {
1020 std::string nstring = input;
1021 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'_'), nstring.end());
1022 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'\''), nstring.end());
1023 return integral_conversion(nstring, output);
1025 if(input.compare(0, 2,
"0o") == 0 || input.compare(0, 2,
"0O") == 0) {
1028 output_ll = std::strtoll(input.c_str() + 2, &val, 8);
1029 if(errno == ERANGE) {
1032 output =
static_cast<T
>(output_ll);
1033 return (val == (input.c_str() + input.size()) &&
static_cast<std::int64_t
>(output) == output_ll);
1035 if(input.compare(0, 2,
"0b") == 0 || input.compare(0, 2,
"0B") == 0) {
1041 output_ll = std::strtoll(input.c_str() + 2, &val, 2);
1042 if(errno == ERANGE) {
1045 output =
static_cast<T
>(output_ll);
1046 return (val == (input.c_str() + input.size()) &&
static_cast<std::int64_t
>(output) == output_ll);
1053inline std::int64_t to_flag_value(std::string val)
noexcept {
1054 static const std::string trueString(
"true");
1055 static const std::string falseString(
"false");
1056 if(val == trueString) {
1059 if(val == falseString) {
1062 val = detail::to_lower(val);
1063 std::int64_t ret = 0;
1064 if(val.size() == 1) {
1065 if(val[0] >=
'1' && val[0] <=
'9') {
1066 return (
static_cast<std::int64_t
>(val[0]) -
'0');
1086 if(val == trueString || val ==
"on" || val ==
"yes" || val ==
"enable") {
1088 }
else if(val == falseString || val ==
"off" || val ==
"no" || val ==
"disable") {
1091 char *loc_ptr{
nullptr};
1092 ret = std::strtoll(val.c_str(), &loc_ptr, 0);
1093 if(loc_ptr != (val.c_str() + val.size()) && errno == 0) {
1101template <
typename T,
1102 enable_if_t<classify_object<T>::value == object_category::integral_value ||
1103 classify_object<T>::value == object_category::unsigned_integral,
1104 detail::enabler> = detail::dummy>
1105bool lexical_cast(
const std::string &input, T &output) {
1106 return integral_conversion(input, output);
1110template <
typename T,
1111 enable_if_t<classify_object<T>::value == object_category::char_value, detail::enabler> = detail::dummy>
1112bool lexical_cast(
const std::string &input, T &output) {
1113 if(input.size() == 1) {
1114 output =
static_cast<T
>(input[0]);
1117 return integral_conversion(input, output);
1121template <
typename T,
1122 enable_if_t<classify_object<T>::value == object_category::boolean_value, detail::enabler> = detail::dummy>
1123bool lexical_cast(
const std::string &input, T &output) {
1125 auto out = to_flag_value(input);
1128 }
else if(errno == ERANGE) {
1129 output = (input[0] !=
'-');
1137template <
typename T,
1138 enable_if_t<classify_object<T>::value == object_category::floating_point, detail::enabler> = detail::dummy>
1139bool lexical_cast(
const std::string &input, T &output) {
1143 char *val =
nullptr;
1144 auto output_ld = std::strtold(input.c_str(), &val);
1145 output =
static_cast<T
>(output_ld);
1146 if(val == (input.c_str() + input.size())) {
1150 if(input.find_first_of(
"_'") != std::string::npos) {
1151 std::string nstring = input;
1152 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'_'), nstring.end());
1153 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'\''), nstring.end());
1154 return lexical_cast(nstring, output);
1160template <
typename T,
1161 enable_if_t<classify_object<T>::value == object_category::complex_number, detail::enabler> = detail::dummy>
1162bool lexical_cast(
const std::string &input, T &output) {
1163 using XC =
typename wrapped_type<T, double>::type;
1166 bool worked =
false;
1167 auto nloc = str1.find_last_of(
"+-");
1168 if(nloc != std::string::npos && nloc > 0) {
1169 worked = lexical_cast(str1.substr(0, nloc), x);
1170 str1 = str1.substr(nloc);
1171 if(str1.back() ==
'i' || str1.back() ==
'j')
1173 worked = worked && lexical_cast(str1, y);
1175 if(str1.back() ==
'i' || str1.back() ==
'j') {
1177 worked = lexical_cast(str1, y);
1180 worked = lexical_cast(str1, x);
1188 return from_stream(input, output);
1192template <
typename T,
1193 enable_if_t<classify_object<T>::value == object_category::string_assignable, detail::enabler> = detail::dummy>
1194bool lexical_cast(
const std::string &input, T &output) {
1202 enable_if_t<classify_object<T>::value == object_category::string_constructible, detail::enabler> = detail::dummy>
1203bool lexical_cast(
const std::string &input, T &output) {
1211 enable_if_t<classify_object<T>::value == object_category::wstring_assignable, detail::enabler> = detail::dummy>
1212bool lexical_cast(
const std::string &input, T &output) {
1213 output = widen(input);
1219 enable_if_t<classify_object<T>::value == object_category::wstring_constructible, detail::enabler> = detail::dummy>
1220bool lexical_cast(
const std::string &input, T &output) {
1221 output = T{widen(input)};
1226template <
typename T,
1227 enable_if_t<classify_object<T>::value == object_category::enumeration, detail::enabler> = detail::dummy>
1228bool lexical_cast(
const std::string &input, T &output) {
1229 typename std::underlying_type<T>::type val;
1230 if(!integral_conversion(input, val)) {
1233 output =
static_cast<T
>(val);
1238template <
typename T,
1239 enable_if_t<classify_object<T>::value == object_category::wrapper_value &&
1240 std::is_assignable<T &, typename T::value_type>::value,
1241 detail::enabler> = detail::dummy>
1242bool lexical_cast(
const std::string &input, T &output) {
1243 typename T::value_type val;
1244 if(lexical_cast(input, val)) {
1248 return from_stream(input, output);
1251template <
typename T,
1252 enable_if_t<classify_object<T>::value == object_category::wrapper_value &&
1253 !std::is_assignable<T &, typename T::value_type>::value && std::is_assignable<T &, T>::value,
1254 detail::enabler> = detail::dummy>
1255bool lexical_cast(
const std::string &input, T &output) {
1256 typename T::value_type val;
1257 if(lexical_cast(input, val)) {
1261 return from_stream(input, output);
1267 enable_if_t<classify_object<T>::value == object_category::number_constructible, detail::enabler> = detail::dummy>
1268bool lexical_cast(
const std::string &input, T &output) {
1270 if(integral_conversion(input, val)) {
1276 if(lexical_cast(input, dval)) {
1281 return from_stream(input, output);
1287 enable_if_t<classify_object<T>::value == object_category::integer_constructible, detail::enabler> = detail::dummy>
1288bool lexical_cast(
const std::string &input, T &output) {
1290 if(integral_conversion(input, val)) {
1294 return from_stream(input, output);
1300 enable_if_t<classify_object<T>::value == object_category::double_constructible, detail::enabler> = detail::dummy>
1301bool lexical_cast(
const std::string &input, T &output) {
1303 if(lexical_cast(input, val)) {
1307 return from_stream(input, output);
1311template <
typename T,
1312 enable_if_t<classify_object<T>::value == object_category::other && std::is_assignable<T &, int>::value,
1313 detail::enabler> = detail::dummy>
1314bool lexical_cast(
const std::string &input, T &output) {
1316 if(integral_conversion(input, val)) {
1318#pragma warning(push)
1319#pragma warning(disable : 4800)
1332 return from_stream(input, output);
1337template <
typename T,
1338 enable_if_t<classify_object<T>::value == object_category::other && !std::is_assignable<T &, int>::value &&
1339 is_istreamable<T>::value,
1340 detail::enabler> = detail::dummy>
1341bool lexical_cast(
const std::string &input, T &output) {
1342 return from_stream(input, output);
1347template <
typename T,
1348 enable_if_t<classify_object<T>::value == object_category::other && !std::is_assignable<T &, int>::value &&
1349 !is_istreamable<T>::value && !adl_detail::is_lexical_castable<T>::value,
1350 detail::enabler> = detail::dummy>
1351bool lexical_cast(
const std::string & , T & ) {
1352 static_assert(!std::is_same<T, T>::value,
1353 "option object type must have a lexical cast overload or streaming input operator(>>) defined, if it "
1354 "is convertible from another type use the add_option<T, XC>(...) with XC being the known type");
1360template <
typename AssignTo,
1362 enable_if_t<std::is_same<AssignTo, ConvertTo>::value &&
1363 (classify_object<AssignTo>::value == object_category::string_assignable ||
1364 classify_object<AssignTo>::value == object_category::string_constructible ||
1365 classify_object<AssignTo>::value == object_category::wstring_assignable ||
1366 classify_object<AssignTo>::value == object_category::wstring_constructible),
1367 detail::enabler> = detail::dummy>
1368bool lexical_assign(
const std::string &input, AssignTo &output) {
1369 return lexical_cast(input, output);
1373template <
typename AssignTo,
1375 enable_if_t<std::is_same<AssignTo, ConvertTo>::value && std::is_assignable<AssignTo &, AssignTo>::value &&
1376 classify_object<AssignTo>::value != object_category::string_assignable &&
1377 classify_object<AssignTo>::value != object_category::string_constructible &&
1378 classify_object<AssignTo>::value != object_category::wstring_assignable &&
1379 classify_object<AssignTo>::value != object_category::wstring_constructible,
1380 detail::enabler> = detail::dummy>
1381bool lexical_assign(
const std::string &input, AssignTo &output) {
1383 output = AssignTo{};
1387 return lexical_cast(input, output);
1391template <
typename AssignTo,
1393 enable_if_t<std::is_same<AssignTo, ConvertTo>::value && !std::is_assignable<AssignTo &, AssignTo>::value &&
1394 classify_object<AssignTo>::value == object_category::wrapper_value,
1395 detail::enabler> = detail::dummy>
1396bool lexical_assign(
const std::string &input, AssignTo &output) {
1398 typename AssignTo::value_type emptyVal{};
1402 return lexical_cast(input, output);
1407template <
typename AssignTo,
1409 enable_if_t<std::is_same<AssignTo, ConvertTo>::value && !std::is_assignable<AssignTo &, AssignTo>::value &&
1410 classify_object<AssignTo>::value != object_category::wrapper_value &&
1411 std::is_assignable<AssignTo &, int>::value,
1412 detail::enabler> = detail::dummy>
1413bool lexical_assign(
const std::string &input, AssignTo &output) {
1419 if(lexical_cast(input, val)) {
1420#if defined(__clang__)
1422#pragma clang diagnostic push
1423#pragma clang diagnostic ignored "-Wsign-conversion"
1426#if defined(__clang__)
1427#pragma clang diagnostic pop
1435template <
typename AssignTo,
1437 enable_if_t<!std::is_same<AssignTo, ConvertTo>::value && std::is_assignable<AssignTo &, ConvertTo &>::value,
1438 detail::enabler> = detail::dummy>
1439bool lexical_assign(
const std::string &input, AssignTo &output) {
1441 bool parse_result = (!input.empty()) ? lexical_cast(input, val) :
true;
1445 return parse_result;
1452 enable_if_t<!std::is_same<AssignTo, ConvertTo>::value && !std::is_assignable<AssignTo &, ConvertTo &>::value &&
1453 std::is_move_assignable<AssignTo>::value,
1454 detail::enabler> = detail::dummy>
1455bool lexical_assign(
const std::string &input, AssignTo &output) {
1457 bool parse_result = input.empty() ? true : lexical_cast(input, val);
1459 output = AssignTo(val);
1461 return parse_result;
1465template <
typename AssignTo,
1467 enable_if_t<classify_object<ConvertTo>::value <= object_category::other &&
1468 classify_object<AssignTo>::value <= object_category::wrapper_value,
1469 detail::enabler> = detail::dummy>
1470bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1471 return lexical_assign<AssignTo, ConvertTo>(strings[0], output);
1476template <
typename AssignTo,
1478 enable_if_t<(type_count<AssignTo>::value <= 2) && expected_count<AssignTo>::value == 1 &&
1479 is_tuple_like<ConvertTo>::value && type_count_base<ConvertTo>::value == 2,
1480 detail::enabler> = detail::dummy>
1481bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1483 using FirstType =
typename std::remove_const<typename std::tuple_element<0, ConvertTo>::type>::type;
1484 using SecondType =
typename std::tuple_element<1, ConvertTo>::type;
1487 bool retval = lexical_assign<FirstType, FirstType>(strings[0], v1);
1488 retval = retval && lexical_assign<SecondType, SecondType>((strings.size() > 1) ? strings[1] : std::string{}, v2);
1490 output = AssignTo{v1, v2};
1496template <
class AssignTo,
1498 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1499 type_count<ConvertTo>::value == 1,
1500 detail::enabler> = detail::dummy>
1501bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1502 output.erase(output.begin(), output.end());
1503 if(strings.empty()) {
1506 if(strings.size() == 1 && strings[0] ==
"{}") {
1509 bool skip_remaining =
false;
1510 if(strings.size() == 2 && strings[0] ==
"{}" && is_separator(strings[1])) {
1511 skip_remaining =
true;
1513 for(
const auto &elem : strings) {
1514 typename AssignTo::value_type out;
1515 bool retval = lexical_assign<typename AssignTo::value_type, typename ConvertTo::value_type>(elem, out);
1519 output.insert(output.end(), std::move(out));
1520 if(skip_remaining) {
1524 return (!output.empty());
1528template <class AssignTo, class ConvertTo, enable_if_t<is_complex<ConvertTo>::value, detail::enabler> = detail::dummy>
1529bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output) {
1531 if(strings.size() >= 2 && !strings[1].empty()) {
1532 using XC2 =
typename wrapped_type<ConvertTo, double>::type;
1534 auto str1 = strings[1];
1535 if(str1.back() ==
'i' || str1.back() ==
'j') {
1538 auto worked = lexical_cast(strings[0], x) && lexical_cast(str1, y);
1540 output = ConvertTo{x, y};
1544 return lexical_assign<AssignTo, ConvertTo>(strings[0], output);
1548template <
class AssignTo,
1550 enable_if_t<is_mutable_container<AssignTo>::value && (expected_count<ConvertTo>::value == 1) &&
1551 (type_count<ConvertTo>::value == 1),
1552 detail::enabler> = detail::dummy>
1553bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1556 output.reserve(strings.size());
1557 for(
const auto &elem : strings) {
1559 output.emplace_back();
1560 retval = retval && lexical_assign<typename AssignTo::value_type, ConvertTo>(elem, output.back());
1562 return (!output.empty()) && retval;
1568template <
class AssignTo,
1570 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1571 type_count_base<ConvertTo>::value == 2,
1572 detail::enabler> = detail::dummy>
1573bool lexical_conversion(std::vector<std::string> strings, AssignTo &output);
1576template <
class AssignTo,
1578 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1579 type_count_base<ConvertTo>::value != 2 &&
1580 ((type_count<ConvertTo>::value > 2) ||
1581 (type_count<ConvertTo>::value > type_count_base<ConvertTo>::value)),
1582 detail::enabler> = detail::dummy>
1583bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output);
1586template <
class AssignTo,
1588 enable_if_t<is_tuple_like<AssignTo>::value && is_tuple_like<ConvertTo>::value &&
1589 (type_count_base<ConvertTo>::value != type_count<ConvertTo>::value ||
1590 type_count<ConvertTo>::value > 2),
1591 detail::enabler> = detail::dummy>
1592bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output);
1596template <
typename AssignTo,
1598 enable_if_t<!is_tuple_like<AssignTo>::value && !is_mutable_container<AssignTo>::value &&
1599 classify_object<ConvertTo>::value != object_category::wrapper_value &&
1600 (is_mutable_container<ConvertTo>::value || type_count<ConvertTo>::value > 2),
1601 detail::enabler> = detail::dummy>
1602bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1604 if(strings.size() > 1 || (!strings.empty() && !(strings.front().empty()))) {
1606 auto retval = lexical_conversion<ConvertTo, ConvertTo>(strings, val);
1607 output = AssignTo{val};
1610 output = AssignTo{};
1615template <
class AssignTo,
class ConvertTo, std::
size_t I>
1616inline typename std::enable_if<(I >= type_count_base<AssignTo>::value),
bool>::type
1617tuple_conversion(
const std::vector<std::string> &, AssignTo &) {
1622template <
class AssignTo,
class ConvertTo>
1623inline typename std::enable_if<!is_mutable_container<ConvertTo>::value && type_count<ConvertTo>::value == 1,
bool>::type
1624tuple_type_conversion(std::vector<std::string> &strings, AssignTo &output) {
1625 auto retval = lexical_assign<AssignTo, ConvertTo>(strings[0], output);
1626 strings.erase(strings.begin());
1631template <
class AssignTo,
class ConvertTo>
1632inline typename std::enable_if<!is_mutable_container<ConvertTo>::value && (type_count<ConvertTo>::value > 1) &&
1633 type_count<ConvertTo>::value == type_count_min<ConvertTo>::value,
1635tuple_type_conversion(std::vector<std::string> &strings, AssignTo &output) {
1636 auto retval = lexical_conversion<AssignTo, ConvertTo>(strings, output);
1637 strings.erase(strings.begin(), strings.begin() + type_count<ConvertTo>::value);
1642template <
class AssignTo,
class ConvertTo>
1643inline typename std::enable_if<is_mutable_container<ConvertTo>::value ||
1644 type_count<ConvertTo>::value != type_count_min<ConvertTo>::value,
1646tuple_type_conversion(std::vector<std::string> &strings, AssignTo &output) {
1648 std::size_t index{subtype_count_min<ConvertTo>::value};
1649 const std::size_t mx_count{subtype_count<ConvertTo>::value};
1650 const std::size_t mx{(std::min)(mx_count, strings.size() - 1)};
1653 if(is_separator(strings[index])) {
1658 bool retval = lexical_conversion<AssignTo, ConvertTo>(
1659 std::vector<std::string>(strings.begin(), strings.begin() +
static_cast<std::ptrdiff_t
>(index)), output);
1660 if(strings.size() > index) {
1661 strings.erase(strings.begin(), strings.begin() +
static_cast<std::ptrdiff_t
>(index) + 1);
1669template <
class AssignTo,
class ConvertTo, std::
size_t I>
1670inline typename std::enable_if<(I < type_count_base<AssignTo>::value),
bool>::type
1671tuple_conversion(std::vector<std::string> strings, AssignTo &output) {
1673 using ConvertToElement =
typename std::
1674 conditional<is_tuple_like<ConvertTo>::value,
typename std::tuple_element<I, ConvertTo>::type, ConvertTo>::type;
1675 if(!strings.empty()) {
1676 retval = retval && tuple_type_conversion<typename std::tuple_element<I, AssignTo>::type, ConvertToElement>(
1677 strings, std::get<I>(output));
1679 retval = retval && tuple_conversion<AssignTo, ConvertTo, I + 1>(std::move(strings), output);
1684template <
class AssignTo,
1686 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1687 type_count_base<ConvertTo>::value == 2,
1689bool lexical_conversion(std::vector<std::string> strings, AssignTo &output) {
1691 while(!strings.empty()) {
1693 typename std::remove_const<typename std::tuple_element<0, typename ConvertTo::value_type>::type>::type v1;
1694 typename std::tuple_element<1, typename ConvertTo::value_type>::type v2;
1695 bool retval = tuple_type_conversion<decltype(v1), decltype(v1)>(strings, v1);
1696 if(!strings.empty()) {
1697 retval = retval && tuple_type_conversion<decltype(v2), decltype(v2)>(strings, v2);
1700 output.insert(output.end(),
typename AssignTo::value_type{v1, v2});
1705 return (!output.empty());
1709template <
class AssignTo,
1711 enable_if_t<is_tuple_like<AssignTo>::value && is_tuple_like<ConvertTo>::value &&
1712 (type_count_base<ConvertTo>::value != type_count<ConvertTo>::value ||
1713 type_count<ConvertTo>::value > 2),
1715bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1717 !is_tuple_like<ConvertTo>::value || type_count_base<AssignTo>::value == type_count_base<ConvertTo>::value,
1718 "if the conversion type is defined as a tuple it must be the same size as the type you are converting to");
1719 return tuple_conversion<AssignTo, ConvertTo, 0>(strings, output);
1723template <
class AssignTo,
1725 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1726 type_count_base<ConvertTo>::value != 2 &&
1727 ((type_count<ConvertTo>::value > 2) ||
1728 (type_count<ConvertTo>::value > type_count_base<ConvertTo>::value)),
1730bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1733 std::vector<std::string> temp;
1735 std::size_t icount{0};
1736 std::size_t xcm{type_count<ConvertTo>::value};
1737 auto ii_max = strings.size();
1738 while(ii < ii_max) {
1739 temp.push_back(strings[ii]);
1742 if(icount == xcm || is_separator(temp.back()) || ii == ii_max) {
1743 if(
static_cast<int>(xcm) > type_count_min<ConvertTo>::value && is_separator(temp.back())) {
1746 typename AssignTo::value_type temp_out;
1748 lexical_conversion<typename AssignTo::value_type, typename ConvertTo::value_type>(temp, temp_out);
1753 output.insert(output.end(), std::move(temp_out));
1761template <
typename AssignTo,
1763 enable_if_t<classify_object<ConvertTo>::value == object_category::wrapper_value &&
1764 std::is_assignable<ConvertTo &, ConvertTo>::value,
1765 detail::enabler> = detail::dummy>
1766bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output) {
1767 if(strings.empty() || strings.front().empty()) {
1768 output = ConvertTo{};
1771 typename ConvertTo::value_type val;
1772 if(lexical_conversion<typename ConvertTo::value_type, typename ConvertTo::value_type>(strings, val)) {
1773 output = ConvertTo{val};
1780template <
typename AssignTo,
1782 enable_if_t<classify_object<ConvertTo>::value == object_category::wrapper_value &&
1783 !std::is_assignable<AssignTo &, ConvertTo>::value,
1784 detail::enabler> = detail::dummy>
1785bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output) {
1786 using ConvertType =
typename ConvertTo::value_type;
1787 if(strings.empty() || strings.front().empty()) {
1788 output = ConvertType{};
1792 if(lexical_conversion<typename ConvertTo::value_type, typename ConvertTo::value_type>(strings, val)) {
1800inline std::string sum_string_vector(
const std::vector<std::string> &values) {
1804 for(
const auto &arg : values) {
1806 auto comp = lexical_cast(arg, tv);
1809 auto fv = detail::to_flag_value(arg);
1810 fail = (errno != 0);
1814 tv =
static_cast<double>(fv);
1819 for(
const auto &arg : values) {
1823 std::ostringstream out;
Definition TypeTools.hpp:96
Check for complex.
Definition TypeTools.hpp:235
Definition TypeTools.hpp:177
Check for input streamability.
Definition TypeTools.hpp:224
Definition TypeTools.hpp:213
Definition TypeTools.hpp:298
This can be specialized to override the type deduction for IsMember.
Definition TypeTools.hpp:81
not a pointer
Definition TypeTools.hpp:115
Definition TypeTools.hpp:125
Definition TypeTools.hpp:260
Definition TypeTools.hpp:280
Definition TypeTools.hpp:291
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
Adaptor for set-like structure: This just wraps a normal container in a few utilities that do almost ...
Definition TypeTools.hpp:130
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
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:500
Set of overloads to get the type size of an object.
Definition TypeTools.hpp:497
This will only trigger for actual void type.
Definition TypeTools.hpp:310
This will only trigger for actual void type.
Definition TypeTools.hpp:503
template to get the underlying value type if it exists or use a default
Definition TypeTools.hpp:485
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
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