\hypertarget{variant_8h}{}\doxysection{kblib/variant.h File Reference}
\label{variant_8h}\index{kblib/variant.h@{kblib/variant.h}}


Provides utilities for working with std\+::variant more expressively and more efficiently.  


{\ttfamily \#include \char`\"{}convert.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}logic.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}tdecl.\+h\char`\"{}}\newline
{\ttfamily \#include $<$cstddef$>$}\newline
{\ttfamily \#include $<$new$>$}\newline
{\ttfamily \#include $<$variant$>$}\newline
Include dependency graph for variant.\+h\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{variant_8h__incl}
\end{center}
\end{figure}
This graph shows which files directly or indirectly include this file\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{variant_8h__dep__incl}
\end{center}
\end{figure}
\doxysubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \mbox{\hyperlink{structkblib_1_1is__variant__like}{kblib\+::is\+\_\+variant\+\_\+like$<$ T $>$}}
\item 
struct \mbox{\hyperlink{structkblib_1_1visitor}{kblib\+::visitor$<$ Ts $>$}}
\begin{DoxyCompactList}\small\item\em Helper class for std\+::visiting a std\+::variant. \end{DoxyCompactList}\item 
struct \mbox{\hyperlink{structkblib_1_1detail_1_1tuple__type}{kblib\+::detail\+::tuple\+\_\+type$<$ T $>$}}
\begin{DoxyCompactList}\small\item\em Given a std\+::variant T, provides the member type which is a tuple of the same types. \end{DoxyCompactList}\item 
struct \mbox{\hyperlink{structkblib_1_1detail_1_1tuple__type_3_01std_1_1variant_3_01_ts_8_8_8_01_4_01_4}{kblib\+::detail\+::tuple\+\_\+type$<$ std\+::variant$<$ Ts... $>$ $>$}}
\begin{DoxyCompactList}\small\item\em Given a std\+::variant T, provides the member type which is a tuple of the same types. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Namespaces}
\begin{DoxyCompactItemize}
\item 
namespace \mbox{\hyperlink{namespacekblib}{kblib}}
\begin{DoxyCompactList}\small\item\em The main namespace in which all entities from kblib are defined. \end{DoxyCompactList}\item 
namespace \mbox{\hyperlink{namespacekblib_1_1detail}{kblib\+::detail}}
\begin{DoxyCompactList}\small\item\em The namespace used for implementation details within kblib. \end{DoxyCompactList}\item 
namespace \mbox{\hyperlink{namespacekblib_1_1literals}{kblib\+::literals}}
\end{DoxyCompactItemize}
\doxysubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$typename T $>$ }\\using \mbox{\hyperlink{namespacekblib_1_1detail_aa7631710f2a34cd76087894745e89e8f}{kblib\+::detail\+::tuple\+\_\+type\+\_\+t}} = typename tuple\+\_\+type$<$ T $>$\+::type
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$typename To , typename... Ts$>$ }\\auto \mbox{\hyperlink{namespacekblib_a5f8aab063bc452b4a3c659a795bcd877}{kblib\+::coerce}} (const std\+::variant$<$ Ts... $>$ \&v) -\/$>$ To
\begin{DoxyCompactList}\small\item\em Lexically converts the value of v (no matter its type) to type To. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename To , typename... Ts$>$ }\\auto \mbox{\hyperlink{namespacekblib_a29192473be72ea5a4451ad3c16c160a6}{kblib\+::static\+\_\+coerce}} (const std\+::variant$<$ Ts... $>$ \&v) -\/$>$ To
\begin{DoxyCompactList}\small\item\em static\+\_\+casts the value of v (no matter its type) to type To. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename To , typename... Ts$>$ }\\auto \mbox{\hyperlink{namespacekblib_ae56f85ba1bf0712f3d28db56c231976f}{kblib\+::lexical\+\_\+coerce}} (const std\+::variant$<$ Ts... $>$ \&v) -\/$>$ To
\begin{DoxyCompactList}\small\item\em Lexically converts the value of v (no matter its type) to type To. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename... Ts$>$ }\\\mbox{\hyperlink{namespacekblib_a8df9aed23f5d515ec52f68275e43014b}{kblib\+::visitor}} (Ts...) -\/$>$ visitor$<$ Ts... $>$
\item 
{\footnotesize template$<$typename Variant , typename F , std\+::size\+\_\+t... Is$>$ }\\constexpr auto \mbox{\hyperlink{namespacekblib_1_1detail_a281d17d136e8e95233607f0c8c049f8b}{kblib\+::detail\+::indexed\+\_\+visitor\+\_\+impl}} (std\+::index\+\_\+sequence$<$ Is... $>$) -\/$>$ auto
\begin{DoxyCompactList}\small\item\em Generates an array of function pointers which will unwrap the variant and pass the index to the function. \end{DoxyCompactList}\item 
{\footnotesize template$<$char... Cs$>$ }\\constexpr auto \mbox{\hyperlink{namespacekblib_1_1literals_acebb1a7951fb28c5fa6648429b883edc}{kblib\+::literals\+::operator\char`\"{}\char`\"{}\+\_\+vi}} ()
\item 
{\footnotesize template$<$typename Variant , typename... Fs$>$ }\\constexpr auto \mbox{\hyperlink{namespacekblib_a7600c651ddd193dfeb5d294732ab1e69}{kblib\+::visit\+\_\+indexed}} (Variant \&\&variant, Fs \&\&... fs) -\/$>$ decltype(auto)
\begin{DoxyCompactList}\small\item\em Visit a variant, but pass the index (as an integral\+\_\+constant) to the visitor. This allows for a visitor of a variant with duplicated types to maintain index information. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename To , typename From $>$ }\\constexpr auto \mbox{\hyperlink{namespacekblib_a8f75832450fffa41112f9035e75c405a}{kblib\+::variant\+\_\+cast}} (From \&\&v) -\/$>$ To
\begin{DoxyCompactList}\small\item\em Promotes an input variant to a super-\/variant. That is, one which provides at least the same set of types. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename V , typename F , typename... Fs$>$ }\\constexpr auto \mbox{\hyperlink{namespacekblib_af1f6dd52b7ce14276ab5509700c6acf1}{kblib\+::visit}} (V \&\&v, F \&\&f, Fs \&\&... fs) -\/$>$ decltype(auto)
\begin{DoxyCompactList}\small\item\em Wraps std\+::visit to provide an interface taking one variant and any number of functors providing an overload set. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename V , typename F , std\+::size\+\_\+t I, std\+::size\+\_\+t... Is$>$ }\\constexpr decltype(auto) \mbox{\hyperlink{namespacekblib_1_1detail_adbf7e44a7b2e088009073f064b96bb37}{kblib\+::detail\+::visit\+\_\+impl}} (V \&\&v, F \&\&f, std\+::index\+\_\+sequence$<$ I, Is... $>$)
\item 
{\footnotesize template$<$typename V , typename F , std\+::size\+\_\+t I, std\+::size\+\_\+t... Is$>$ }\\constexpr void \mbox{\hyperlink{namespacekblib_1_1detail_ae841d811176370353222931de4d3ced9}{kblib\+::detail\+::visit\+\_\+nop\+\_\+impl}} (V \&\&v, F \&\&f, std\+::index\+\_\+sequence$<$ I, Is... $>$)
\item 
{\footnotesize template$<$typename V , typename F , typename... Fs$>$ }\\constexpr auto \mbox{\hyperlink{namespacekblib_ac780c4d9780fb9b46be0669d377e1e9b}{kblib\+::visit2}} (V \&\&v, F \&\&f, Fs \&\&... fs) -\/$>$ decltype(auto)
\item 
{\footnotesize template$<$typename V , typename F , typename... Fs$>$ }\\constexpr auto \mbox{\hyperlink{namespacekblib_a76752fc2ac3634b95ba226b1324dc0b9}{kblib\+::visit2\+\_\+nop}} (V \&\&v, F \&\&f, Fs \&\&... fs) -\/$>$ void
\item 
{\footnotesize template$<$typename V $>$ }\\constexpr auto \mbox{\hyperlink{namespacekblib_aac6dcc14f17288a30b9a439fbd9ed3c2}{kblib\+::visit}} (V \&v) -\/$>$ auto
\begin{DoxyCompactList}\small\item\em Two-\/step visiting interface. Takes a variant, and returns an object which can be called with any number of callable arguments, builds an overload set from them, and visits the variant. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$typename T , typename  = void$>$ }\\constexpr bool \mbox{\hyperlink{namespacekblib_a6b22bbd4d3c7abe1c7ec7be007c11028}{kblib\+::is\+\_\+variant\+\_\+like\+\_\+v}} = false
\item 
{\footnotesize template$<$typename F , typename... Ts$>$ }\\constexpr bool \mbox{\hyperlink{namespacekblib_1_1detail_a2293617d6736d88b70f8da0959654f87}{kblib\+::detail\+::invocable\+\_\+with\+\_\+all\+\_\+v}} = (ignore\+\_\+t$<$std\+::invoke\+\_\+result\+\_\+t$<$F, Ts$>$, std\+::true\+\_\+type$>$\+::value and ...)
\item 
{\footnotesize template$<$typename Callable , typename Variant $>$ }\\constexpr bool \mbox{\hyperlink{namespacekblib_1_1detail_afb0630c3153474d6a942e9137b80350b}{kblib\+::detail\+::v\+\_\+invocable\+\_\+with\+\_\+all\+\_\+v}} = false
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Provides utilities for working with std\+::variant more expressively and more efficiently. 

\begin{DoxyAuthor}{Author}
killerbee 
\end{DoxyAuthor}
\begin{DoxyDate}{Date}
2019-\/2021 
\end{DoxyDate}
\begin{DoxyCopyright}{Copyright}
GNU General Public Licence v3.\+0 
\end{DoxyCopyright}


Definition in file \mbox{\hyperlink{variant_8h_source}{variant.\+h}}.

