\hypertarget{variant_8h_source}{}\doxysection{variant.\+h}
\label{variant_8h_source}\index{kblib/variant.h@{kblib/variant.h}}
\mbox{\hyperlink{variant_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00001}00001 \textcolor{comment}{/* *****************************************************************************}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00002}00002 \textcolor{comment}{ * kblib is a general utility library for C++14 and C++17, intended to provide}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00003}00003 \textcolor{comment}{ * performant high-\/level abstractions and more expressive ways to do simple}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00004}00004 \textcolor{comment}{ * things.}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00005}00005 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00006}00006 \textcolor{comment}{ * Copyright (c) 2021 killerbee}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00007}00007 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00008}00008 \textcolor{comment}{ * This program is free software: you can redistribute it and/or modify}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00009}00009 \textcolor{comment}{ * it under the terms of the GNU General Public License as published by}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00010}00010 \textcolor{comment}{ * the Free Software Foundation, either version 3 of the License, or}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00011}00011 \textcolor{comment}{ * (at your option) any later version.}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00012}00012 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00013}00013 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00014}00014 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00015}00015 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00016}00016 \textcolor{comment}{ * GNU General Public License for more details.}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00017}00017 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00018}00018 \textcolor{comment}{ * You should have received a copy of the GNU General Public License}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00019}00019 \textcolor{comment}{ * along with this program.  If not, see <https://www.gnu.org/licenses/>.}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00020}00020 \textcolor{comment}{ * ****************************************************************************/}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00021}00021 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00032}00032 \textcolor{preprocessor}{\#ifndef KBLIB\_VARIANT\_H}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00033}00033 \textcolor{preprocessor}{\#define KBLIB\_VARIANT\_H}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00034}00034 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00035}00035 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{convert_8h}{convert.h}}"{}}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00036}00036 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{logic_8h}{logic.h}}"{}}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00037}00037 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{tdecl_8h}{tdecl.h}}"{}}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00038}00038 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00039}00039 \textcolor{preprocessor}{\#include <cstddef>}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00040}00040 \textcolor{preprocessor}{\#include <new>}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00041}00041 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00042}00042 \textcolor{preprocessor}{\#if KBLIB\_USE\_CXX17}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00043}00043 \textcolor{preprocessor}{\#  include <variant>}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00044}00044 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00045}00045 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00046}00046 \textcolor{keyword}{namespace }\mbox{\hyperlink{tdecl_8h_a4b5c574c663a392148218cd4410fd7a1}{KBLIB\_NS}} \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00047}00047 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00048}00048 \textcolor{preprocessor}{\#if KBLIB\_USE\_CXX17}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00049}00049 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00050}00050 \textcolor{keyword}{template} <\textcolor{keyword}{typename} T, \textcolor{keyword}{typename} = \textcolor{keywordtype}{void}>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00051}\mbox{\hyperlink{namespacekblib_a6b22bbd4d3c7abe1c7ec7be007c11028}{00051}} \textcolor{keyword}{constexpr} \textcolor{keyword}{inline} \textcolor{keywordtype}{bool} \mbox{\hyperlink{namespacekblib_a6b22bbd4d3c7abe1c7ec7be007c11028}{is\_variant\_like\_v}} = \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00052}00052 \textcolor{keyword}{template} <\textcolor{keyword}{typename} T>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00053}00053 \textcolor{keyword}{constexpr} \textcolor{keyword}{inline} \textcolor{keywordtype}{bool} is\_variant\_like\_v<T, void\_t<std::variant\_size<T>>> = \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00054}00054 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00055}00055 \textcolor{keyword}{template} <\textcolor{keyword}{typename} T>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00056}\mbox{\hyperlink{structkblib_1_1is__variant__like}{00056}} \textcolor{keyword}{struct }\mbox{\hyperlink{structkblib_1_1is__variant__like}{is\_variant\_like}} : \mbox{\hyperlink{namespacekblib_aab6846d277428f1e4b61ced2ed64dd0b}{std::bool\_constant}}<is\_variant\_like\_v<T>> \{\};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00057}00057 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00066}00066 \textcolor{keyword}{template} <\textcolor{keyword}{typename} To, \textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00067}\mbox{\hyperlink{namespacekblib_a5f8aab063bc452b4a3c659a795bcd877}{00067}} \mbox{\hyperlink{tdecl_8h_a7f62d0731631a0e7675f45924b7f5ea0}{KBLIB\_NODISCARD}} [[deprecated(\textcolor{stringliteral}{"{}Use new lexical\_coerce instead."{}})]] \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a5f8aab063bc452b4a3c659a795bcd877}{coerce}}(}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00068}00068     \textcolor{keyword}{const} std::variant<Ts...>\& v) -\/> To \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00069}00069    \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_aac6dcc14f17288a30b9a439fbd9ed3c2}{std::visit}}([](\textcolor{keyword}{const} \textcolor{keyword}{auto}\& t) -\/> To \{ \textcolor{keywordflow}{return} lexical\_cast<To>(t); \},}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00070}00070                      v);}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00071}00071 \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00072}00072 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00079}00079 \textcolor{keyword}{template} <\textcolor{keyword}{typename} To, \textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00080}\mbox{\hyperlink{namespacekblib_a29192473be72ea5a4451ad3c16c160a6}{00080}} \mbox{\hyperlink{tdecl_8h_a7f62d0731631a0e7675f45924b7f5ea0}{KBLIB\_NODISCARD}} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a29192473be72ea5a4451ad3c16c160a6}{static\_coerce}}(\textcolor{keyword}{const} std::variant<Ts...>\& v) -\/> To \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00081}00081    \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_aac6dcc14f17288a30b9a439fbd9ed3c2}{std::visit}}([](\textcolor{keyword}{const} \textcolor{keyword}{auto}\& t) -\/> To \{ \textcolor{keywordflow}{return} \textcolor{keyword}{static\_cast<}To\textcolor{keyword}{>}(t); \}, v);}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00082}00082 \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00083}00083 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00090}00090 \textcolor{keyword}{template} <\textcolor{keyword}{typename} To, \textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00091}\mbox{\hyperlink{namespacekblib_ae56f85ba1bf0712f3d28db56c231976f}{00091}} \mbox{\hyperlink{tdecl_8h_a7f62d0731631a0e7675f45924b7f5ea0}{KBLIB\_NODISCARD}} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_ae56f85ba1bf0712f3d28db56c231976f}{lexical\_coerce}}(\textcolor{keyword}{const} std::variant<Ts...>\& v) -\/> To \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00092}00092    \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_aac6dcc14f17288a30b9a439fbd9ed3c2}{std::visit}}([](\textcolor{keyword}{const} \textcolor{keyword}{auto}\& t) \{ \textcolor{keywordflow}{return} lexical\_cast<To>(t); \}, v);}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00093}00093 \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00094}00094 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00101}00101 \textcolor{keyword}{template} <\textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00102}\mbox{\hyperlink{structkblib_1_1visitor}{00102}} \textcolor{keyword}{struct }\mbox{\hyperlink{structkblib_1_1visitor}{visitor}} : Ts... \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00103}00103    \textcolor{keyword}{using }Ts::operator()...;}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00104}00104 \};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00105}00105 \textcolor{keyword}{template} <\textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00106}\mbox{\hyperlink{namespacekblib_a8df9aed23f5d515ec52f68275e43014b}{00106}} \mbox{\hyperlink{namespacekblib_a8df9aed23f5d515ec52f68275e43014b}{visitor}}(Ts...) -\/> \mbox{\hyperlink{structkblib_1_1visitor}{visitor}}<Ts...>;}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00107}00107 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00108}00108 \textcolor{keyword}{namespace }detail \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00109}00109 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00114}00114    \textcolor{keyword}{template} <\textcolor{keyword}{typename} T>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00115}\mbox{\hyperlink{structkblib_1_1detail_1_1tuple__type}{00115}}    \textcolor{keyword}{struct }\mbox{\hyperlink{structkblib_1_1detail_1_1tuple__type}{tuple\_type}} \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00119}\mbox{\hyperlink{structkblib_1_1detail_1_1tuple__type_a12c8167ce13497a5ed1df1970c32d309}{00119}}       \textcolor{keyword}{using }\mbox{\hyperlink{structkblib_1_1detail_1_1tuple__type_a12c8167ce13497a5ed1df1970c32d309}{type}} = std::tuple<>;}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00120}00120    \};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00125}00125    \textcolor{keyword}{template} <\textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00126}\mbox{\hyperlink{structkblib_1_1detail_1_1tuple__type_3_01std_1_1variant_3_01_ts_8_8_8_01_4_01_4}{00126}}    \textcolor{keyword}{struct }\mbox{\hyperlink{structkblib_1_1detail_1_1tuple__type}{tuple\_type}}<\mbox{\hyperlink{namespacestd}{std}}::variant<Ts...>> \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00130}\mbox{\hyperlink{structkblib_1_1detail_1_1tuple__type_3_01std_1_1variant_3_01_ts_8_8_8_01_4_01_4_a485f3d4c4ac73d17df780378421e5ce9}{00130}}       \textcolor{keyword}{using }\mbox{\hyperlink{structkblib_1_1detail_1_1tuple__type_3_01std_1_1variant_3_01_ts_8_8_8_01_4_01_4_a485f3d4c4ac73d17df780378421e5ce9}{type}} = std::tuple<Ts...>;}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00131}00131    \};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00135}00135    \textcolor{keyword}{template} <\textcolor{keyword}{typename} T>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00136}\mbox{\hyperlink{namespacekblib_1_1detail_aa7631710f2a34cd76087894745e89e8f}{00136}}    \textcolor{keyword}{using }\mbox{\hyperlink{namespacekblib_1_1detail_aa7631710f2a34cd76087894745e89e8f}{tuple\_type\_t}} = \textcolor{keyword}{typename} \mbox{\hyperlink{structkblib_1_1detail_1_1tuple__type_a12c8167ce13497a5ed1df1970c32d309}{tuple\_type<T>::type}};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00137}00137 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00142}00142    \textcolor{keyword}{template} <\textcolor{keyword}{typename} Variant, \textcolor{keyword}{typename} F, std::size\_t... Is>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00143}\mbox{\hyperlink{namespacekblib_1_1detail_a281d17d136e8e95233607f0c8c049f8b}{00143}}    \textcolor{keyword}{constexpr} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_1_1detail_a281d17d136e8e95233607f0c8c049f8b}{indexed\_visitor\_impl}}(std::index\_sequence<Is...>) -\/> \textcolor{keyword}{auto} \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00144}00144       \textcolor{keywordflow}{return} std::array\{+[](Variant\&\& variant, F\&\& f) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00145}00145          \textcolor{keywordflow}{return} std::forward<F>(f)(}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00146}00146              \mbox{\hyperlink{structkblib_1_1constant}{kblib::constant<std::size\_t, Is>}}\{\},}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00147}00147              std::get<Is>(std::forward<Variant>(variant)));}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00148}00148       \}...\};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00149}00149    \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00150}00150 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00151}00151 \} \textcolor{comment}{// namespace detail}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00152}00152 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00153}00153 \textcolor{keyword}{inline} \textcolor{keyword}{namespace }literals \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00154}00154 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00155}00155    \textcolor{keyword}{template} <\textcolor{keywordtype}{char}... Cs>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00156}\mbox{\hyperlink{namespacekblib_1_1literals_acebb1a7951fb28c5fa6648429b883edc}{00156}}    \mbox{\hyperlink{tdecl_8h_a7f62d0731631a0e7675f45924b7f5ea0}{KBLIB\_NODISCARD}} \textcolor{keyword}{constexpr} \textcolor{keyword}{auto} \textcolor{keyword}{operator}\textcolor{stringliteral}{"{}"{}}\_vi() \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00157}00157       \textcolor{keyword}{constexpr} \textcolor{keywordtype}{char} arr[] = \{Cs...\};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00158}00158       \textcolor{keywordflow}{return} std::in\_place\_index\_t<parse\_integer<std::size\_t>(arr)>\{\};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00159}00159    \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00160}00160 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00161}00161 \} \textcolor{comment}{// namespace literals}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00162}00162 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00175}00175 \textcolor{keyword}{template} <\textcolor{keyword}{typename} Variant, \textcolor{keyword}{typename}... Fs>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00176}\mbox{\hyperlink{namespacekblib_a7600c651ddd193dfeb5d294732ab1e69}{00176}} \textcolor{keyword}{constexpr} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a7600c651ddd193dfeb5d294732ab1e69}{visit\_indexed}}(Variant\&\& variant, Fs\&\&... fs) -\/> \textcolor{keyword}{decltype}(\textcolor{keyword}{auto}) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00177}00177    \textcolor{keywordflow}{if} (variant.valueless\_by\_exception()) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00178}00178       \textcolor{keywordflow}{throw} std::bad\_variant\_access();}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00179}00179    \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00180}00180    \textcolor{keyword}{using }visitor\_t = \textcolor{keyword}{decltype}(\mbox{\hyperlink{structkblib_1_1visitor}{visitor}}\{std::forward<Fs>(fs)...\});}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00181}00181    \textcolor{keywordflow}{return} detail::indexed\_visitor\_impl<Variant, visitor\_t>(}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00182}00182        std::make\_index\_sequence<}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00183}00183            std::variant\_size\_v<std::decay\_t<Variant>>>())[variant.index()](}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00184}00184        std::forward<Variant>(variant), \mbox{\hyperlink{structkblib_1_1visitor}{visitor}}\{std::forward<Fs>(fs)...\});}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00185}00185 \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00186}00186 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00193}00193 \textcolor{keyword}{template} <\textcolor{keyword}{typename} To, \textcolor{keyword}{typename} From>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00194}\mbox{\hyperlink{namespacekblib_a8f75832450fffa41112f9035e75c405a}{00194}} \mbox{\hyperlink{tdecl_8h_a7f62d0731631a0e7675f45924b7f5ea0}{KBLIB\_NODISCARD}} \textcolor{keyword}{constexpr} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a8f75832450fffa41112f9035e75c405a}{variant\_cast}}(From\&\& v) -\/> To \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00195}00195    \textcolor{keyword}{static\_assert}(contains\_types\_v<detail::tuple\_type\_t<std::decay\_t<To>>,}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00196}00196                                   \mbox{\hyperlink{namespacekblib_1_1detail_aa7631710f2a34cd76087894745e89e8f}{detail::tuple\_type\_t<std::decay\_t<From>}}>>,}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00197}00197                  \textcolor{stringliteral}{"{}To must include all types in From"{}});}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00198}00198 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00199}00199    \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_a7600c651ddd193dfeb5d294732ab1e69}{visit\_indexed}}(std::forward<From>(v), [](\textcolor{keyword}{auto} \mbox{\hyperlink{structkblib_1_1constant}{constant}}, \textcolor{keyword}{auto}\&\& x) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00200}00200       \textcolor{keywordflow}{return} To(std::in\_place\_type<}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00201}00201                     std::variant\_alternative\_t<\mbox{\hyperlink{structkblib_1_1constant}{constant}}, std::decay\_t<From>>>,}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00202}00202                 std::forward<\textcolor{keyword}{decltype}(x)>(x));}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00203}00203    \});}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00204}00204 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00205}00205    \textcolor{comment}{// return std::visit([](auto\&\& x) \{ return std::forward<decltype(x)>(x); \},}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00206}00206    \textcolor{comment}{//                   std::forward<From>(v));}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00207}00207 \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00208}00208 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00220}00220 \textcolor{keyword}{template} <\textcolor{keyword}{typename} V, \textcolor{keyword}{typename} F, \textcolor{keyword}{typename}... Fs>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00221}\mbox{\hyperlink{namespacekblib_af1f6dd52b7ce14276ab5509700c6acf1}{00221}} \mbox{\hyperlink{tdecl_8h_a7f62d0731631a0e7675f45924b7f5ea0}{KBLIB\_NODISCARD}} \textcolor{keyword}{constexpr} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_aac6dcc14f17288a30b9a439fbd9ed3c2}{visit}}(V\&\& v, F\&\& f, Fs\&\&... fs)}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00222}00222     -\/> \textcolor{keyword}{decltype}(\textcolor{keyword}{auto}) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00223}00223    \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_aac6dcc14f17288a30b9a439fbd9ed3c2}{std::visit}}(\mbox{\hyperlink{structkblib_1_1visitor}{visitor}}\{std::forward<F>(f), std::forward<Fs>(fs)...\},}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00224}00224                      std::forward<V>(v));}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00225}00225 \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00226}00226 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00227}00227 \textcolor{keyword}{namespace }detail \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00228}00228 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00229}00229    \textcolor{keyword}{template} <\textcolor{keyword}{typename} F, \textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00230}\mbox{\hyperlink{namespacekblib_1_1detail_a2293617d6736d88b70f8da0959654f87}{00230}}    \textcolor{keyword}{constexpr} \textcolor{keywordtype}{bool} \mbox{\hyperlink{namespacekblib_1_1detail_a2293617d6736d88b70f8da0959654f87}{invocable\_with\_all\_v}}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00231}00231        = (\mbox{\hyperlink{namespacekblib_a3cec35675700d7e15c9139e0497768e6}{ignore\_t<std::invoke\_result\_t<F, Ts>}}, std::true\_type>::value and ...);}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00232}00232 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00233}00233    \textcolor{keyword}{template} <\textcolor{keyword}{typename} Callable, \textcolor{keyword}{typename} Variant>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00234}\mbox{\hyperlink{namespacekblib_1_1detail_afb0630c3153474d6a942e9137b80350b}{00234}}    \textcolor{keyword}{constexpr} \textcolor{keywordtype}{bool} \mbox{\hyperlink{namespacekblib_1_1detail_afb0630c3153474d6a942e9137b80350b}{v\_invocable\_with\_all\_v}} = \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00235}00235 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00236}00236    \textcolor{keyword}{template} <\textcolor{keyword}{typename} F, \textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00237}00237    \textcolor{keyword}{constexpr} \textcolor{keywordtype}{bool} \mbox{\hyperlink{namespacekblib_1_1detail_afb0630c3153474d6a942e9137b80350b}{v\_invocable\_with\_all\_v}}<}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00238}00238        F, std::variant<Ts...>> = \mbox{\hyperlink{namespacekblib_1_1detail_a2293617d6736d88b70f8da0959654f87}{invocable\_with\_all\_v}}<F, Ts...>;}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00239}00239 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00240}00240    \textcolor{keyword}{template} <\textcolor{keyword}{typename} F, \textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00241}00241    \textcolor{keyword}{constexpr} \textcolor{keywordtype}{bool} \mbox{\hyperlink{namespacekblib_1_1detail_afb0630c3153474d6a942e9137b80350b}{v\_invocable\_with\_all\_v}}<}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00242}00242        F, \textcolor{keyword}{const} std::variant<Ts...>> = \mbox{\hyperlink{namespacekblib_1_1detail_a2293617d6736d88b70f8da0959654f87}{invocable\_with\_all\_v}}<F, \textcolor{keyword}{const} Ts...>;}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00243}00243 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00244}00244    \textcolor{keyword}{template} <\textcolor{keyword}{typename} F, \textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00245}00245    \textcolor{keyword}{constexpr} \textcolor{keywordtype}{bool} \mbox{\hyperlink{namespacekblib_1_1detail_afb0630c3153474d6a942e9137b80350b}{v\_invocable\_with\_all\_v}}<}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00246}00246        F, std::variant<Ts...>\&> = \mbox{\hyperlink{namespacekblib_1_1detail_a2293617d6736d88b70f8da0959654f87}{invocable\_with\_all\_v}}<F, Ts\&...>;}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00247}00247 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00248}00248    \textcolor{keyword}{template} <\textcolor{keyword}{typename} F, \textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00249}00249    \textcolor{keyword}{constexpr} \textcolor{keywordtype}{bool} \mbox{\hyperlink{namespacekblib_1_1detail_afb0630c3153474d6a942e9137b80350b}{v\_invocable\_with\_all\_v}}<}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00250}00250        F, \textcolor{keyword}{const} std::variant<Ts...>\&> = \mbox{\hyperlink{namespacekblib_1_1detail_a2293617d6736d88b70f8da0959654f87}{invocable\_with\_all\_v}}<F, \textcolor{keyword}{const} Ts\&...>;}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00251}00251 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00252}00252    \textcolor{keyword}{template} <\textcolor{keyword}{typename} F, \textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00253}00253    \textcolor{keyword}{constexpr} \textcolor{keywordtype}{bool} \mbox{\hyperlink{namespacekblib_1_1detail_afb0630c3153474d6a942e9137b80350b}{v\_invocable\_with\_all\_v}}<}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00254}00254        F, std::variant<Ts...>\&\&> = \mbox{\hyperlink{namespacekblib_1_1detail_a2293617d6736d88b70f8da0959654f87}{invocable\_with\_all\_v}}<F, Ts\&\&...>;}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00255}00255 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00256}00256    \textcolor{keyword}{template} <\textcolor{keyword}{typename} F, \textcolor{keyword}{typename}... Ts>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00257}00257    \textcolor{keyword}{constexpr} \textcolor{keywordtype}{bool} \mbox{\hyperlink{namespacekblib_1_1detail_afb0630c3153474d6a942e9137b80350b}{v\_invocable\_with\_all\_v}}<}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00258}00258        F, \textcolor{keyword}{const} std::variant<Ts...>\&\&> = \mbox{\hyperlink{namespacekblib_1_1detail_a2293617d6736d88b70f8da0959654f87}{invocable\_with\_all\_v}}<F, \textcolor{keyword}{const} Ts\&\&...>;}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00259}00259 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00260}00260    \textcolor{keyword}{template} <\textcolor{keyword}{typename} V, \textcolor{keyword}{typename} F, std::size\_t I, std::size\_t... Is>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00261}\mbox{\hyperlink{namespacekblib_1_1detail_adbf7e44a7b2e088009073f064b96bb37}{00261}}    [[gnu::always\_inline]] \textcolor{keyword}{constexpr} \textcolor{keyword}{decltype}(\textcolor{keyword}{auto}) \mbox{\hyperlink{namespacekblib_1_1detail_adbf7e44a7b2e088009073f064b96bb37}{visit\_impl}}(}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00262}00262        V\&\& v, F\&\& f, std::index\_sequence<I, Is...>) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00263}00263       \textcolor{keyword}{static\_assert}(I < std::variant\_size\_v<std::decay\_t<V>>);}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00264}00264       \textcolor{keywordflow}{if} (\textcolor{keyword}{auto}* p = std::get\_if<I>(\&v)) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00265}00265          \textcolor{keywordflow}{return} std::forward<F>(f)(}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00266}00266              \textcolor{keyword}{static\_cast<}decltype(std::get<I>(std::forward<V>(v)))\textcolor{keyword}{>}(*p));}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00267}00267       \} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} \textcolor{keyword}{constexpr} (\textcolor{keyword}{sizeof}...(Is) > 0) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00268}00268          \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_1_1detail_adbf7e44a7b2e088009073f064b96bb37}{visit\_impl}}(std::forward<V>(v), std::forward<F>(f),}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00269}00269                            std::index\_sequence<Is...>\{\});}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00270}00270       \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00271}00271          \textcolor{keywordflow}{throw} std::bad\_variant\_access();}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00272}00272       \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00273}00273    \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00274}00274 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00275}00275    \textcolor{keyword}{template} <\textcolor{keyword}{typename} V, \textcolor{keyword}{typename} F, std::size\_t I, std::size\_t... Is>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00276}\mbox{\hyperlink{namespacekblib_1_1detail_ae841d811176370353222931de4d3ced9}{00276}}    [[gnu::always\_inline]] \textcolor{keyword}{constexpr} \textcolor{keywordtype}{void} \mbox{\hyperlink{namespacekblib_1_1detail_ae841d811176370353222931de4d3ced9}{visit\_nop\_impl}}(}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00277}00277        V\&\& v, F\&\& f, std::index\_sequence<I, Is...>) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00278}00278       \textcolor{keyword}{static\_assert}(I < std::variant\_size\_v<std::decay\_t<V>>);}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00279}00279       \textcolor{keywordflow}{if} (\textcolor{keyword}{auto}* p = std::get\_if<I>(\&v)) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00280}00280          std::forward<F>(f)(}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00281}00281              \textcolor{keyword}{static\_cast<}decltype(std::get<I>(std::forward<V>(v)))\textcolor{keyword}{>}(*p));}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00282}00282          \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00283}00283       \} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} \textcolor{keyword}{constexpr} (\textcolor{keyword}{sizeof}...(Is) > 0) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00284}00284          \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_1_1detail_ae841d811176370353222931de4d3ced9}{visit\_nop\_impl}}(std::forward<V>(v), std::forward<F>(f),}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00285}00285                                std::index\_sequence<Is...>\{\});}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00286}00286       \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00287}00287          \textcolor{comment}{// valueless\_by\_exception case}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00288}00288          \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00289}00289       \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00290}00290    \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00291}00291 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00292}00292 \} \textcolor{comment}{// namespace detail}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00293}00293 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00294}00294 \textcolor{keyword}{template} <\textcolor{keyword}{typename} V, \textcolor{keyword}{typename} F, \textcolor{keyword}{typename}... Fs>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00295}\mbox{\hyperlink{namespacekblib_ac780c4d9780fb9b46be0669d377e1e9b}{00295}} [[gnu::always\_inline]] \textcolor{keyword}{constexpr} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_ac780c4d9780fb9b46be0669d377e1e9b}{visit2}}(V\&\& v, F\&\& f, Fs\&\&... fs)}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00296}00296     -\/> \textcolor{keyword}{decltype}(\textcolor{keyword}{auto}) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00297}00297    \textcolor{keyword}{auto} visitor\_obj = \mbox{\hyperlink{structkblib_1_1visitor}{visitor}}\{std::forward<F>(f), std::forward<Fs>(fs)...\};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00298}00298    \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_1_1detail_afb0630c3153474d6a942e9137b80350b}{detail::v\_invocable\_with\_all\_v}}<\textcolor{keyword}{decltype}(visitor\_obj), V\&\&>,}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00299}00299                  \textcolor{stringliteral}{"{}Some variant types not accepted by any visitors."{}});}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00300}00300    \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_1_1detail_adbf7e44a7b2e088009073f064b96bb37}{detail::visit\_impl}}(}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00301}00301        std::forward<V>(v), std::move(visitor\_obj),}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00302}00302        std::make\_index\_sequence<std::variant\_size\_v<std::decay\_t<V>>>\{\});}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00303}00303 \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00304}00304 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00305}00305 \textcolor{keyword}{template} <\textcolor{keyword}{typename} V, \textcolor{keyword}{typename} F, \textcolor{keyword}{typename}... Fs>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00306}\mbox{\hyperlink{namespacekblib_a76752fc2ac3634b95ba226b1324dc0b9}{00306}} [[gnu::always\_inline]] \textcolor{keyword}{constexpr} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a76752fc2ac3634b95ba226b1324dc0b9}{visit2\_nop}}(V\&\& v, F\&\& f, Fs\&\&... fs)}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00307}00307     -\/> \textcolor{keywordtype}{void} \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00308}00308    \textcolor{keyword}{auto} visitor\_obj = \mbox{\hyperlink{structkblib_1_1visitor}{visitor}}\{std::forward<F>(f), std::forward<Fs>(fs)...\};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00309}00309    \textcolor{keyword}{static\_assert}(\mbox{\hyperlink{namespacekblib_1_1detail_afb0630c3153474d6a942e9137b80350b}{detail::v\_invocable\_with\_all\_v}}<\textcolor{keyword}{decltype}(visitor\_obj), V\&\&>,}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00310}00310                  \textcolor{stringliteral}{"{}Some variant types not accepted by any visitors."{}});}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00311}00311    \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_1_1detail_ae841d811176370353222931de4d3ced9}{detail::visit\_nop\_impl}}(}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00312}00312        std::forward<V>(v), visitor\_obj,}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00313}00313        std::make\_index\_sequence<std::variant\_size\_v<std::decay\_t<V>>>\{\});}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00314}00314 \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00315}00315 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00331}00331 \textcolor{keyword}{template} <\textcolor{keyword}{typename} V>}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00332}\mbox{\hyperlink{namespacekblib_aac6dcc14f17288a30b9a439fbd9ed3c2}{00332}} \mbox{\hyperlink{tdecl_8h_a7f62d0731631a0e7675f45924b7f5ea0}{KBLIB\_NODISCARD}} \textcolor{keyword}{constexpr} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_aac6dcc14f17288a30b9a439fbd9ed3c2}{visit}}(V\& v) -\/> \textcolor{keyword}{auto} \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00333}00333    \textcolor{keywordflow}{return} [\&v](\textcolor{keyword}{auto}... fs) -\/> \textcolor{keyword}{decltype}(\textcolor{keyword}{auto}) \{}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00334}00334       \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_af1f6dd52b7ce14276ab5509700c6acf1}{kblib::visit}}(v, std::forward<\textcolor{keyword}{decltype}(fs)>(fs)...);}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00335}00335    \};}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00336}00336 \}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00337}00337 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00338}00338 \textcolor{preprocessor}{\#endif }\textcolor{comment}{// KBLIB\_USE\_CXX17}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00339}00339 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00340}00340 \} \textcolor{comment}{// namespace KBLIB\_NS}}
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00341}00341 }
\DoxyCodeLine{\Hypertarget{variant_8h_source_l00342}00342 \textcolor{preprocessor}{\#endif }\textcolor{comment}{// KBLIB\_VARIANT\_H}}

\end{DoxyCode}
