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 {};
300 template <typename SS, enable_if_t<!is_complex<SS>::value, detail::enabler> = detail::dummy>
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;
307 static constexpr bool value =
decltype(test<S>(0))::value;
312 static const int value{0};
318 typename std::enable_if<!is_tuple_like<T>::value && !is_mutable_container<T>::value &&
319 !std::is_void<T>::value>::type> {
320 static constexpr int value{1};
325struct type_count_base<T, typename std::enable_if<is_tuple_like<T>::value && !is_mutable_container<T>::value>::type> {
326 static constexpr int value{
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> {
336template <typename T, enable_if_t<std::is_convertible<T, std::string>::value, detail::enabler> = detail::dummy>
337auto to_string(T &&value) ->
decltype(std::forward<T>(value)) {
338 return std::forward<T>(value);
343 enable_if_t<std::is_constructible<std::string, T>::value && !std::is_convertible<T, std::string>::value,
344 detail::enabler> = detail::dummy>
345std::string to_string(T &&value) {
346 return std::string(value);
351 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
352 is_ostreamable<T>::value,
353 detail::enabler> = detail::dummy>
354std::string to_string(T &&value) {
355 std::stringstream stream;
364 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
365 !is_ostreamable<T>::value && is_tuple_like<T>::value && type_count_base<T>::value == 1,
366 detail::enabler> = detail::dummy>
367inline std::string to_string(T &&value);
371 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
372 !is_ostreamable<T>::value && is_tuple_like<T>::value && type_count_base<T>::value >= 2,
373 detail::enabler> = detail::dummy>
374inline std::string to_string(T &&value);
379 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
380 !is_ostreamable<T>::value && !is_readable_container<typename std::remove_const<T>::type>::value &&
381 !is_tuple_like<T>::value,
382 detail::enabler> = detail::dummy>
383inline std::string to_string(T &&) {
389 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
390 !is_ostreamable<T>::value && is_readable_container<T>::value,
391 detail::enabler> = detail::dummy>
392inline std::string to_string(T &&variable) {
393 auto cval = variable.begin();
394 auto end = variable.end();
398 std::vector<std::string> defaults;
400 defaults.emplace_back(CLI::detail::to_string(*cval));
403 return {
"[" + detail::join(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 &&
419 !is_ostreamable<T>::value && is_tuple_like<T>::value && type_count_base<T>::value == 1,
421inline std::string to_string(T &&value) {
422 return to_string(std::get<0>(value));
427 enable_if_t<!std::is_convertible<T, std::string>::value && !std::is_constructible<std::string, T>::value &&
428 !is_ostreamable<T>::value && is_tuple_like<T>::value && type_count_base<T>::value >= 2,
430inline std::string to_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,
455 enable_if_t<std::is_same<T1, T2>::value, detail::enabler> = detail::dummy>
456auto checked_to_string(T &&value) ->
decltype(to_string(std::forward<T>(value))) {
457 return to_string(std::forward<T>(value));
461template <
typename T1,
464 enable_if_t<!std::is_same<T1, T2>::value, detail::enabler> = detail::dummy>
465std::string checked_to_string(T &&) {
466 return std::string{};
469template <typename T, enable_if_t<std::is_arithmetic<T>::value, detail::enabler> = detail::dummy>
470std::string value_string(
const T &value) {
471 return std::to_string(value);
474template <typename T, enable_if_t<std::is_enum<T>::value, detail::enabler> = detail::dummy>
475std::string value_string(
const T &value) {
476 return std::to_string(
static_cast<typename std::underlying_type<T>::type
>(value));
480 enable_if_t<!std::is_enum<T>::value && !std::is_arithmetic<T>::value, detail::enabler> = detail::dummy>
481auto value_string(
const T &value) ->
decltype(to_string(value)) {
482 return to_string(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 {
505 static const int value{0};
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> {
513 static constexpr int value{1};
517template <
typename T>
struct type_count<T, typename std::enable_if<is_complex<T>::value>::type> {
518 static constexpr int value{2};
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 {
553 static constexpr int value{is_mutable_container<T>::value ? expected_max_vector_size : type_count<T>::value};
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
603 ? ((type_count<T>::value < expected_max_vector_size) ? type_count<T>::value : 0)
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> {
621 static constexpr int value{expected_max_vector_size};
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};
827 enable_if_t<classify_object<T>::value == object_category::char_value, detail::enabler> = detail::dummy>
828constexpr const char *type_name() {
833 enable_if_t<classify_object<T>::value == object_category::integral_value ||
834 classify_object<T>::value == object_category::integer_constructible,
835 detail::enabler> = detail::dummy>
836constexpr const char *type_name() {
841 enable_if_t<classify_object<T>::value == object_category::unsigned_integral, detail::enabler> = detail::dummy>
842constexpr const char *type_name() {
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,
850 detail::enabler> = detail::dummy>
851constexpr const char *type_name() {
857 enable_if_t<classify_object<T>::value == object_category::enumeration, detail::enabler> = detail::dummy>
858constexpr const char *type_name() {
864 enable_if_t<classify_object<T>::value == object_category::boolean_value, detail::enabler> = detail::dummy>
865constexpr const char *type_name() {
871 enable_if_t<classify_object<T>::value == object_category::complex_number, detail::enabler> = detail::dummy>
872constexpr const char *type_name() {
878 enable_if_t<classify_object<T>::value >= object_category::string_assignable &&
879 classify_object<T>::value <= object_category::other,
880 detail::enabler> = detail::dummy>
881constexpr const char *type_name() {
886 enable_if_t<classify_object<T>::value == object_category::tuple_value && type_count_base<T>::value >= 2,
887 detail::enabler> = detail::dummy>
888std::string type_name();
892 enable_if_t<classify_object<T>::value == object_category::container_value ||
893 classify_object<T>::value == object_category::wrapper_value,
894 detail::enabler> = detail::dummy>
895std::string type_name();
899 enable_if_t<classify_object<T>::value == object_category::tuple_value && type_count_base<T>::value == 1,
900 detail::enabler> = detail::dummy>
901inline std::string type_name() {
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() ==
',')
923 enable_if_t<classify_object<T>::value == object_category::tuple_value && type_count_base<T>::value >= 2,
925inline std::string type_name() {
926 auto tname = std::string(1,
'[') + tuple_name<T, 0>();
927 tname.push_back(
']');
933 enable_if_t<classify_object<T>::value == object_category::container_value ||
934 classify_object<T>::value == object_category::wrapper_value,
936inline std::string type_name() {
937 return type_name<typename T::value_type>();
943template <typename T, enable_if_t<std::is_unsigned<T>::value, detail::enabler> = detail::dummy>
944bool integral_conversion(
const std::string &input, T &output)
noexcept {
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());
969 return integral_conversion(nstring, output);
971 if(input.compare(0, 2,
"0o") == 0 || input.compare(0, 2,
"0O") == 0) {
974 output_ll = std::strtoull(input.c_str() + 2, &val, 8);
975 if(errno == ERANGE) {
978 output =
static_cast<T
>(output_ll);
979 return (val == (input.c_str() + input.size()) &&
static_cast<std::uint64_t
>(output) == output_ll);
981 if(input.compare(0, 2,
"0b") == 0 || input.compare(0, 2,
"0B") == 0) {
987 output_ll = std::strtoull(input.c_str() + 2, &val, 2);
988 if(errno == ERANGE) {
991 output =
static_cast<T
>(output_ll);
992 return (val == (input.c_str() + input.size()) &&
static_cast<std::uint64_t
>(output) == output_ll);
999template <typename T, enable_if_t<std::is_signed<T>::value, detail::enabler> = detail::dummy>
1000bool integral_conversion(
const std::string &input, T &output)
noexcept {
1004 char *val =
nullptr;
1006 std::int64_t output_ll = std::strtoll(input.c_str(), &val, 0);
1007 if(errno == ERANGE) {
1010 output =
static_cast<T
>(output_ll);
1011 if(val == (input.c_str() + input.size()) &&
static_cast<std::int64_t
>(output) == output_ll) {
1014 if(input ==
"true") {
1016 output =
static_cast<T
>(1);
1020 if(input.find_first_of(
"_'") != std::string::npos) {
1021 std::string nstring = input;
1022 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'_'), nstring.end());
1023 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'\''), nstring.end());
1024 return integral_conversion(nstring, output);
1026 if(input.compare(0, 2,
"0o") == 0 || input.compare(0, 2,
"0O") == 0) {
1029 output_ll = std::strtoll(input.c_str() + 2, &val, 8);
1030 if(errno == ERANGE) {
1033 output =
static_cast<T
>(output_ll);
1034 return (val == (input.c_str() + input.size()) &&
static_cast<std::int64_t
>(output) == output_ll);
1036 if(input.compare(0, 2,
"0b") == 0 || input.compare(0, 2,
"0B") == 0) {
1042 output_ll = std::strtoll(input.c_str() + 2, &val, 2);
1043 if(errno == ERANGE) {
1046 output =
static_cast<T
>(output_ll);
1047 return (val == (input.c_str() + input.size()) &&
static_cast<std::int64_t
>(output) == output_ll);
1054inline std::int64_t to_flag_value(std::string val)
noexcept {
1055 static const std::string trueString(
"true");
1056 static const std::string falseString(
"false");
1057 if(val == trueString) {
1060 if(val == falseString) {
1063 val = detail::to_lower(val);
1064 std::int64_t ret = 0;
1065 if(val.size() == 1) {
1066 if(val[0] >=
'1' && val[0] <=
'9') {
1067 return (
static_cast<std::int64_t
>(val[0]) -
'0');
1087 if(val == trueString || val ==
"on" || val ==
"yes" || val ==
"enable") {
1089 }
else if(val == falseString || val ==
"off" || val ==
"no" || val ==
"disable") {
1092 char *loc_ptr{
nullptr};
1093 ret = std::strtoll(val.c_str(), &loc_ptr, 0);
1094 if(loc_ptr != (val.c_str() + val.size()) && errno == 0) {
1102template <
typename T,
1103 enable_if_t<classify_object<T>::value == object_category::integral_value ||
1104 classify_object<T>::value == object_category::unsigned_integral,
1105 detail::enabler> = detail::dummy>
1106bool lexical_cast(
const std::string &input, T &output) {
1107 return integral_conversion(input, output);
1111template <
typename T,
1112 enable_if_t<classify_object<T>::value == object_category::char_value, detail::enabler> = detail::dummy>
1113bool lexical_cast(
const std::string &input, T &output) {
1114 if(input.size() == 1) {
1115 output =
static_cast<T
>(input[0]);
1118 return integral_conversion(input, output);
1122template <
typename T,
1123 enable_if_t<classify_object<T>::value == object_category::boolean_value, detail::enabler> = detail::dummy>
1124bool lexical_cast(
const std::string &input, T &output) {
1126 auto out = to_flag_value(input);
1129 }
else if(errno == ERANGE) {
1130 output = (input[0] !=
'-');
1138template <
typename T,
1139 enable_if_t<classify_object<T>::value == object_category::floating_point, detail::enabler> = detail::dummy>
1140bool lexical_cast(
const std::string &input, T &output) {
1144 char *val =
nullptr;
1145 auto output_ld = std::strtold(input.c_str(), &val);
1146 output =
static_cast<T
>(output_ld);
1147 if(val == (input.c_str() + input.size())) {
1151 if(input.find_first_of(
"_'") != std::string::npos) {
1152 std::string nstring = input;
1153 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'_'), nstring.end());
1154 nstring.erase(std::remove(nstring.begin(), nstring.end(),
'\''), nstring.end());
1155 return lexical_cast(nstring, output);
1161template <
typename T,
1162 enable_if_t<classify_object<T>::value == object_category::complex_number, detail::enabler> = detail::dummy>
1163bool lexical_cast(
const std::string &input, T &output) {
1164 using XC =
typename wrapped_type<T, double>::type;
1167 bool worked =
false;
1168 auto nloc = str1.find_last_of(
"+-");
1169 if(nloc != std::string::npos && nloc > 0) {
1170 worked = lexical_cast(str1.substr(0, nloc), x);
1171 str1 = str1.substr(nloc);
1172 if(str1.back() ==
'i' || str1.back() ==
'j')
1174 worked = worked && lexical_cast(str1, y);
1176 if(str1.back() ==
'i' || str1.back() ==
'j') {
1178 worked = lexical_cast(str1, y);
1181 worked = lexical_cast(str1, x);
1189 return from_stream(input, output);
1193template <
typename T,
1194 enable_if_t<classify_object<T>::value == object_category::string_assignable, detail::enabler> = detail::dummy>
1195bool lexical_cast(
const std::string &input, T &output) {
1203 enable_if_t<classify_object<T>::value == object_category::string_constructible, detail::enabler> = detail::dummy>
1204bool lexical_cast(
const std::string &input, T &output) {
1212 enable_if_t<classify_object<T>::value == object_category::wstring_assignable, detail::enabler> = detail::dummy>
1213bool lexical_cast(
const std::string &input, T &output) {
1214 output = widen(input);
1220 enable_if_t<classify_object<T>::value == object_category::wstring_constructible, detail::enabler> = detail::dummy>
1221bool lexical_cast(
const std::string &input, T &output) {
1222 output = T{widen(input)};
1227template <
typename T,
1228 enable_if_t<classify_object<T>::value == object_category::enumeration, detail::enabler> = detail::dummy>
1229bool lexical_cast(
const std::string &input, T &output) {
1230 typename std::underlying_type<T>::type val;
1231 if(!integral_conversion(input, val)) {
1234 output =
static_cast<T
>(val);
1239template <
typename T,
1240 enable_if_t<classify_object<T>::value == object_category::wrapper_value &&
1241 std::is_assignable<T &, typename T::value_type>::value,
1242 detail::enabler> = detail::dummy>
1243bool lexical_cast(
const std::string &input, T &output) {
1244 typename T::value_type val;
1245 if(lexical_cast(input, val)) {
1249 return from_stream(input, output);
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 && std::is_assignable<T &, T>::value,
1255 detail::enabler> = detail::dummy>
1256bool lexical_cast(
const std::string &input, T &output) {
1257 typename T::value_type val;
1258 if(lexical_cast(input, val)) {
1262 return from_stream(input, output);
1268 enable_if_t<classify_object<T>::value == object_category::number_constructible, detail::enabler> = detail::dummy>
1269bool lexical_cast(
const std::string &input, T &output) {
1271 if(integral_conversion(input, val)) {
1277 if(lexical_cast(input, dval)) {
1282 return from_stream(input, output);
1288 enable_if_t<classify_object<T>::value == object_category::integer_constructible, detail::enabler> = detail::dummy>
1289bool lexical_cast(
const std::string &input, T &output) {
1291 if(integral_conversion(input, val)) {
1295 return from_stream(input, output);
1301 enable_if_t<classify_object<T>::value == object_category::double_constructible, detail::enabler> = detail::dummy>
1302bool lexical_cast(
const std::string &input, T &output) {
1304 if(lexical_cast(input, val)) {
1308 return from_stream(input, output);
1312template <
typename T,
1313 enable_if_t<classify_object<T>::value == object_category::other && std::is_assignable<T &, int>::value,
1314 detail::enabler> = detail::dummy>
1315bool lexical_cast(
const std::string &input, T &output) {
1317 if(integral_conversion(input, val)) {
1319#pragma warning(push)
1320#pragma warning(disable : 4800)
1333 return from_stream(input, output);
1338template <
typename T,
1339 enable_if_t<classify_object<T>::value == object_category::other && !std::is_assignable<T &, int>::value &&
1340 is_istreamable<T>::value,
1341 detail::enabler> = detail::dummy>
1342bool lexical_cast(
const std::string &input, T &output) {
1343 return from_stream(input, output);
1348template <
typename T,
1349 enable_if_t<classify_object<T>::value == object_category::other && !std::is_assignable<T &, int>::value &&
1350 !is_istreamable<T>::value && !adl_detail::is_lexical_castable<T>::value,
1351 detail::enabler> = detail::dummy>
1352bool lexical_cast(
const std::string & , T & ) {
1353 static_assert(!std::is_same<T, T>::value,
1354 "option object type must have a lexical cast overload or streaming input operator(>>) defined, if it "
1355 "is convertible from another type use the add_option<T, XC>(...) with XC being the known type");
1361template <
typename AssignTo,
1363 enable_if_t<std::is_same<AssignTo, ConvertTo>::value &&
1364 (classify_object<AssignTo>::value == object_category::string_assignable ||
1365 classify_object<AssignTo>::value == object_category::string_constructible ||
1366 classify_object<AssignTo>::value == object_category::wstring_assignable ||
1367 classify_object<AssignTo>::value == object_category::wstring_constructible),
1368 detail::enabler> = detail::dummy>
1369bool lexical_assign(
const std::string &input, AssignTo &output) {
1370 return lexical_cast(input, output);
1374template <
typename AssignTo,
1376 enable_if_t<std::is_same<AssignTo, ConvertTo>::value && std::is_assignable<AssignTo &, AssignTo>::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,
1381 detail::enabler> = detail::dummy>
1382bool lexical_assign(
const std::string &input, AssignTo &output) {
1384 output = AssignTo{};
1388 return lexical_cast(input, output);
1392template <
typename AssignTo,
1394 enable_if_t<std::is_same<AssignTo, ConvertTo>::value && !std::is_assignable<AssignTo &, AssignTo>::value &&
1395 classify_object<AssignTo>::value == object_category::wrapper_value,
1396 detail::enabler> = detail::dummy>
1397bool lexical_assign(
const std::string &input, AssignTo &output) {
1399 typename AssignTo::value_type emptyVal{};
1403 return lexical_cast(input, output);
1408template <
typename AssignTo,
1410 enable_if_t<std::is_same<AssignTo, ConvertTo>::value && !std::is_assignable<AssignTo &, AssignTo>::value &&
1411 classify_object<AssignTo>::value != object_category::wrapper_value &&
1412 std::is_assignable<AssignTo &, int>::value,
1413 detail::enabler> = detail::dummy>
1414bool lexical_assign(
const std::string &input, AssignTo &output) {
1420 if(lexical_cast(input, val)) {
1421#if defined(__clang__)
1423#pragma clang diagnostic push
1424#pragma clang diagnostic ignored "-Wsign-conversion"
1427#if defined(__clang__)
1428#pragma clang diagnostic pop
1436template <
typename AssignTo,
1438 enable_if_t<!std::is_same<AssignTo, ConvertTo>::value && std::is_assignable<AssignTo &, ConvertTo &>::value,
1439 detail::enabler> = detail::dummy>
1440bool lexical_assign(
const std::string &input, AssignTo &output) {
1442 bool parse_result = (!input.empty()) ? lexical_cast(input, val) :
true;
1446 return parse_result;
1453 enable_if_t<!std::is_same<AssignTo, ConvertTo>::value && !std::is_assignable<AssignTo &, ConvertTo &>::value &&
1454 std::is_move_assignable<AssignTo>::value,
1455 detail::enabler> = detail::dummy>
1456bool lexical_assign(
const std::string &input, AssignTo &output) {
1458 bool parse_result = input.empty() ? true : lexical_cast(input, val);
1460 output = AssignTo(val);
1462 return parse_result;
1466template <
typename AssignTo,
1468 enable_if_t<classify_object<ConvertTo>::value <= object_category::other &&
1469 classify_object<AssignTo>::value <= object_category::wrapper_value,
1470 detail::enabler> = detail::dummy>
1471bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1472 return lexical_assign<AssignTo, ConvertTo>(strings[0], output);
1477template <
typename AssignTo,
1479 enable_if_t<(type_count<AssignTo>::value <= 2) && expected_count<AssignTo>::value == 1 &&
1480 is_tuple_like<ConvertTo>::value && type_count_base<ConvertTo>::value == 2,
1481 detail::enabler> = detail::dummy>
1482bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1484 using FirstType =
typename std::remove_const<typename std::tuple_element<0, ConvertTo>::type>::type;
1485 using SecondType =
typename std::tuple_element<1, ConvertTo>::type;
1488 bool retval = lexical_assign<FirstType, FirstType>(strings[0], v1);
1489 retval = retval && lexical_assign<SecondType, SecondType>((strings.size() > 1) ? strings[1] : std::string{}, v2);
1491 output = AssignTo{v1, v2};
1497template <
class AssignTo,
1499 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1500 type_count<ConvertTo>::value == 1,
1501 detail::enabler> = detail::dummy>
1502bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1503 output.erase(output.begin(), output.end());
1504 if(strings.empty()) {
1507 if(strings.size() == 1 && strings[0] ==
"{}") {
1510 bool skip_remaining =
false;
1511 if(strings.size() == 2 && strings[0] ==
"{}" && is_separator(strings[1])) {
1512 skip_remaining =
true;
1514 for(
const auto &elem : strings) {
1515 typename AssignTo::value_type out;
1516 bool retval = lexical_assign<typename AssignTo::value_type, typename ConvertTo::value_type>(elem, out);
1520 output.insert(output.end(), std::move(out));
1521 if(skip_remaining) {
1525 return (!output.empty());
1529template <class AssignTo, class ConvertTo, enable_if_t<is_complex<ConvertTo>::value, detail::enabler> = detail::dummy>
1530bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output) {
1532 if(strings.size() >= 2 && !strings[1].empty()) {
1533 using XC2 =
typename wrapped_type<ConvertTo, double>::type;
1535 auto str1 = strings[1];
1536 if(str1.back() ==
'i' || str1.back() ==
'j') {
1539 auto worked = lexical_cast(strings[0], x) && lexical_cast(str1, y);
1541 output = ConvertTo{x, y};
1545 return lexical_assign<AssignTo, ConvertTo>(strings[0], output);
1549template <
class AssignTo,
1551 enable_if_t<is_mutable_container<AssignTo>::value && (expected_count<ConvertTo>::value == 1) &&
1552 (type_count<ConvertTo>::value == 1),
1553 detail::enabler> = detail::dummy>
1554bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1557 output.reserve(strings.size());
1558 for(
const auto &elem : strings) {
1560 output.emplace_back();
1561 retval = retval && lexical_assign<typename AssignTo::value_type, ConvertTo>(elem, output.back());
1563 return (!output.empty()) && retval;
1569template <
class AssignTo,
1571 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1572 type_count_base<ConvertTo>::value == 2,
1573 detail::enabler> = detail::dummy>
1574bool lexical_conversion(std::vector<std::string> strings, AssignTo &output);
1577template <
class AssignTo,
1579 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1580 type_count_base<ConvertTo>::value != 2 &&
1581 ((type_count<ConvertTo>::value > 2) ||
1582 (type_count<ConvertTo>::value > type_count_base<ConvertTo>::value)),
1583 detail::enabler> = detail::dummy>
1584bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output);
1587template <
class AssignTo,
1589 enable_if_t<is_tuple_like<AssignTo>::value && is_tuple_like<ConvertTo>::value &&
1590 (type_count_base<ConvertTo>::value != type_count<ConvertTo>::value ||
1591 type_count<ConvertTo>::value > 2),
1592 detail::enabler> = detail::dummy>
1593bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output);
1597template <
typename AssignTo,
1599 enable_if_t<!is_tuple_like<AssignTo>::value && !is_mutable_container<AssignTo>::value &&
1600 classify_object<ConvertTo>::value != object_category::wrapper_value &&
1601 (is_mutable_container<ConvertTo>::value || type_count<ConvertTo>::value > 2),
1602 detail::enabler> = detail::dummy>
1603bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1605 if(strings.size() > 1 || (!strings.empty() && !(strings.front().empty()))) {
1607 auto retval = lexical_conversion<ConvertTo, ConvertTo>(strings, val);
1608 output = AssignTo{val};
1611 output = AssignTo{};
1616template <
class AssignTo,
class ConvertTo, std::
size_t I>
1617inline typename std::enable_if<(I >= type_count_base<AssignTo>::value),
bool>::type
1618tuple_conversion(
const std::vector<std::string> &, AssignTo &) {
1623template <
class AssignTo,
class ConvertTo>
1624inline typename std::enable_if<!is_mutable_container<ConvertTo>::value && type_count<ConvertTo>::value == 1,
bool>::type
1625tuple_type_conversion(std::vector<std::string> &strings, AssignTo &output) {
1626 auto retval = lexical_assign<AssignTo, ConvertTo>(strings[0], output);
1627 strings.erase(strings.begin());
1632template <
class AssignTo,
class ConvertTo>
1633inline typename std::enable_if<!is_mutable_container<ConvertTo>::value && (type_count<ConvertTo>::value > 1) &&
1634 type_count<ConvertTo>::value == type_count_min<ConvertTo>::value,
1636tuple_type_conversion(std::vector<std::string> &strings, AssignTo &output) {
1637 auto retval = lexical_conversion<AssignTo, ConvertTo>(strings, output);
1638 strings.erase(strings.begin(), strings.begin() + type_count<ConvertTo>::value);
1643template <
class AssignTo,
class ConvertTo>
1644inline typename std::enable_if<is_mutable_container<ConvertTo>::value ||
1645 type_count<ConvertTo>::value != type_count_min<ConvertTo>::value,
1647tuple_type_conversion(std::vector<std::string> &strings, AssignTo &output) {
1649 std::size_t index{subtype_count_min<ConvertTo>::value};
1650 const std::size_t mx_count{subtype_count<ConvertTo>::value};
1651 const std::size_t mx{(std::min)(mx_count, strings.size() - 1)};
1654 if(is_separator(strings[index])) {
1659 bool retval = lexical_conversion<AssignTo, ConvertTo>(
1660 std::vector<std::string>(strings.begin(), strings.begin() +
static_cast<std::ptrdiff_t
>(index)), output);
1661 if(strings.size() > index) {
1662 strings.erase(strings.begin(), strings.begin() +
static_cast<std::ptrdiff_t
>(index) + 1);
1670template <
class AssignTo,
class ConvertTo, std::
size_t I>
1671inline typename std::enable_if<(I < type_count_base<AssignTo>::value),
bool>::type
1672tuple_conversion(std::vector<std::string> strings, AssignTo &output) {
1674 using ConvertToElement =
typename std::
1675 conditional<is_tuple_like<ConvertTo>::value,
typename std::tuple_element<I, ConvertTo>::type, ConvertTo>::type;
1676 if(!strings.empty()) {
1677 retval = retval && tuple_type_conversion<typename std::tuple_element<I, AssignTo>::type, ConvertToElement>(
1678 strings, std::get<I>(output));
1680 retval = retval && tuple_conversion<AssignTo, ConvertTo, I + 1>(std::move(strings), output);
1685template <
class AssignTo,
1687 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1688 type_count_base<ConvertTo>::value == 2,
1690bool lexical_conversion(std::vector<std::string> strings, AssignTo &output) {
1692 while(!strings.empty()) {
1694 typename std::remove_const<typename std::tuple_element<0, typename ConvertTo::value_type>::type>::type v1;
1695 typename std::tuple_element<1, typename ConvertTo::value_type>::type v2;
1696 bool retval = tuple_type_conversion<decltype(v1), decltype(v1)>(strings, v1);
1697 if(!strings.empty()) {
1698 retval = retval && tuple_type_conversion<decltype(v2), decltype(v2)>(strings, v2);
1701 output.insert(output.end(),
typename AssignTo::value_type{v1, v2});
1706 return (!output.empty());
1710template <
class AssignTo,
1712 enable_if_t<is_tuple_like<AssignTo>::value && is_tuple_like<ConvertTo>::value &&
1713 (type_count_base<ConvertTo>::value != type_count<ConvertTo>::value ||
1714 type_count<ConvertTo>::value > 2),
1716bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1718 !is_tuple_like<ConvertTo>::value || type_count_base<AssignTo>::value == type_count_base<ConvertTo>::value,
1719 "if the conversion type is defined as a tuple it must be the same size as the type you are converting to");
1720 return tuple_conversion<AssignTo, ConvertTo, 0>(strings, output);
1724template <
class AssignTo,
1726 enable_if_t<is_mutable_container<AssignTo>::value && is_mutable_container<ConvertTo>::value &&
1727 type_count_base<ConvertTo>::value != 2 &&
1728 ((type_count<ConvertTo>::value > 2) ||
1729 (type_count<ConvertTo>::value > type_count_base<ConvertTo>::value)),
1731bool lexical_conversion(
const std::vector<std ::string> &strings, AssignTo &output) {
1734 std::vector<std::string> temp;
1736 std::size_t icount{0};
1737 std::size_t xcm{type_count<ConvertTo>::value};
1738 auto ii_max = strings.size();
1739 while(ii < ii_max) {
1740 temp.push_back(strings[ii]);
1743 if(icount == xcm || is_separator(temp.back()) || ii == ii_max) {
1744 if(
static_cast<int>(xcm) > type_count_min<ConvertTo>::value && is_separator(temp.back())) {
1747 typename AssignTo::value_type temp_out;
1749 lexical_conversion<typename AssignTo::value_type, typename ConvertTo::value_type>(temp, temp_out);
1754 output.insert(output.end(), std::move(temp_out));
1762template <
typename AssignTo,
1764 enable_if_t<classify_object<ConvertTo>::value == object_category::wrapper_value &&
1765 std::is_assignable<ConvertTo &, ConvertTo>::value,
1766 detail::enabler> = detail::dummy>
1767bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output) {
1768 if(strings.empty() || strings.front().empty()) {
1769 output = ConvertTo{};
1772 typename ConvertTo::value_type val;
1773 if(lexical_conversion<typename ConvertTo::value_type, typename ConvertTo::value_type>(strings, val)) {
1774 output = ConvertTo{val};
1781template <
typename AssignTo,
1783 enable_if_t<classify_object<ConvertTo>::value == object_category::wrapper_value &&
1784 !std::is_assignable<AssignTo &, ConvertTo>::value,
1785 detail::enabler> = detail::dummy>
1786bool lexical_conversion(
const std::vector<std::string> &strings, AssignTo &output) {
1787 using ConvertType =
typename ConvertTo::value_type;
1788 if(strings.empty() || strings.front().empty()) {
1789 output = ConvertType{};
1793 if(lexical_conversion<typename ConvertTo::value_type, typename ConvertTo::value_type>(strings, val)) {
1801inline std::string sum_string_vector(
const std::vector<std::string> &values) {
1805 for(
const auto &arg : values) {
1807 auto comp = lexical_cast(arg, tv);
1810 auto fv = detail::to_flag_value(arg);
1811 fail = (errno != 0);
1815 tv =
static_cast<double>(fv);
1820 for(
const auto &arg : values) {
1824 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:299
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: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
This will only trigger for actual void type.
Definition TypeTools.hpp:504
template to get the underlying value type if it exists or use a default
Definition TypeTools.hpp:486
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