\hypertarget{_w_1_2_work_2_software_2_libraries_2utl_2include_2utl_2meta_2invoke_8h-example}{}\section{W\+:/\+Work/\+Software/\+Libraries/utl/include/utl/meta/invoke.\+h}
Create an invocable from other invocables(quoted metafunctions) by composition. \begin{DoxyNote}{Note}
This implies from N invocables in {\ttfamily Fns} the first N-\/1 has to be unary. Thats because of the \char`\"{}return\char`\"{} type of metafunction. They can only return one type. So for n-\/ary invocables in the N-\/1 places the typelist$<$$>$ is the solution.
\end{DoxyNote}

\begin{DoxyCode}
static\_assert( std::is\_same<
   \mbox{\hyperlink{namespaceutl_1_1meta_a77630cd8adc01f7193f6cb834313d90f}{invoke}}<\mbox{\hyperlink{namespaceutl_1_1meta_a4f0c06cabe66bc73b703eb8509c7bb07}{compose}}<quote<F1>, quote<F2>, quote<F3>>, \textcolor{keywordtype}{int}>, F1<F2<F3<int>>>
>, \textcolor{stringliteral}{""});
\end{DoxyCode}



\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#ifndef \_\_utl\_meta\_invoke\_h\_\_}
\textcolor{preprocessor}{#define \_\_utl\_meta\_invoke\_h\_\_}

\textcolor{preprocessor}{#include <\mbox{\hyperlink{impl_8h}{utl/core/impl.h}}>}
\textcolor{preprocessor}{#include <\mbox{\hyperlink{integral_8h}{utl/meta/integral.h}}>}
\textcolor{preprocessor}{#include <\mbox{\hyperlink{detection_8h}{utl/meta/detection.h}}>}
\textcolor{preprocessor}{#include <\mbox{\hyperlink{operations_8h}{utl/meta/operations.h}}>}

\textcolor{keyword}{namespace }\mbox{\hyperlink{namespaceutl}{utl}} \{
\textcolor{keyword}{namespace }meta\{


   \textcolor{keyword}{template} <\textcolor{keyword}{typename} \_Tp>
   \textcolor{keyword}{struct }identity \{
\textcolor{preprocessor}{   #if defined (UTL\_WORKAROUND\_CWG\_1558)}
      \textcolor{comment}{// redirect unused Ts... via void\_t}
      \textcolor{keyword}{template} <\textcolor{keyword}{typename}... Ts>
      \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1identity_ab13e3134ffe9c6fabb22f67d7b87b2dd}{apply}} = \mbox{\hyperlink{group__type_gaf7089523d21cd405c76985643f31092a}{first\_of}}<\_Tp, \mbox{\hyperlink{group__detection_gae7373c997420d16cf37e542eb3cfa3ad}{void\_t}}<Ts...>>;   
\textcolor{preprocessor}{   #else}
      \textcolor{keyword}{template} <\textcolor{keyword}{typename}...>
      \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1identity_ab13e3134ffe9c6fabb22f67d7b87b2dd}{apply}} = \_Tp;   
\textcolor{preprocessor}{   #endif}
      \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1identity_a9aab221df05f226c227a6e508460f7b7}{type}} = \_Tp;    
   \};

   \textcolor{keyword}{template} <\textcolor{keyword}{typename} \_Tp>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a63c0b6b08f4c1d9bd3c4db7432e9b2af}{identity\_t}} = eval<identity<\_Tp>>;


   \textcolor{keyword}{template} <\textcolor{keyword}{typename} Fn, \textcolor{keyword}{typename}... Args>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a77630cd8adc01f7193f6cb834313d90f}{invoke}} = \textcolor{keyword}{typename} Fn::template \mbox{\hyperlink{namespaceutl_1_1meta_a3f684549221fac60bc8c7979cb4b98f4}{apply}}<Args...>;

   \textcolor{keyword}{template} <\textcolor{keyword}{typename} Fn, \textcolor{keyword}{typename}... Args>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_ac27f3e5f3ec42921d9f8a6bb85560cf1}{invoke\_t}} = \mbox{\hyperlink{namespaceutl_1_1meta_aa5a37adba244ff4286f994111c4c02ea}{eval}}< \mbox{\hyperlink{namespaceutl_1_1meta_a77630cd8adc01f7193f6cb834313d90f}{invoke}} <Fn, Args...>>;


   \textcolor{keyword}{template} <\textcolor{keyword}{template} <\textcolor{keyword}{typename}...> \textcolor{keyword}{class }F>
   \textcolor{keyword}{struct }wrap \{
      \textcolor{keyword}{template} <\textcolor{keyword}{typename}... Args>
      \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1wrap_a71fe22d6a841f27b891ca3344ee97b07}{apply}} = F<Args...>;
   \};

   \textcolor{keyword}{template} <\textcolor{keyword}{typename} T, \textcolor{keyword}{template} <T...> \textcolor{keyword}{class }F>
   \textcolor{keyword}{struct }wrap\_i \{
      \textcolor{comment}{// requires meta::Integral}
      \textcolor{keyword}{template} <\textcolor{keyword}{typename}... Ts>
      \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1wrap__i_a14e7ddd17abbcecf2658a3dd4616e0d2}{apply}} = F<Ts::type::value...>;
   \};

   \textcolor{keyword}{namespace }detail \{

      \textcolor{keyword}{template}<\textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }F, \textcolor{keyword}{typename}... T>
      \textcolor{keyword}{struct }is\_applicable\_ \{
         \textcolor{keyword}{template}<\textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }G, \textcolor{keyword}{typename} = G<T...>>
            \textcolor{keyword}{static} \mbox{\hyperlink{namespaceutl_1_1meta_ae9a5a8fbe8202785f059935af219fb97}{true\_}} \mbox{\hyperlink{structutl_1_1meta_1_1detail_1_1is__applicable___abdbf481cbdd5183b42e3cabdb77d282a}{check}} (\textcolor{keywordtype}{int});  \textcolor{comment}{//< T.. can be passed to G}
         \textcolor{keyword}{template}<\textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class}>
            \textcolor{keyword}{static} \mbox{\hyperlink{namespaceutl_1_1meta_a55511dbaa0adb605ce22dcec11f8d22d}{false\_}} \mbox{\hyperlink{structutl_1_1meta_1_1detail_1_1is__applicable___abdbf481cbdd5183b42e3cabdb77d282a}{check}} (...); \textcolor{comment}{//< all other combinations}

         \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1detail_1_1is__applicable___ababc9a374e6321fb8ded4b2dde19795c}{type}} = decltype(check<F>(0));
      \};

      \textcolor{keyword}{template}<\textcolor{keyword}{typename} F, \textcolor{keyword}{typename}... T>
      \textcolor{keyword}{struct }is\_applicable\_q\_ \{
         \textcolor{keyword}{template}<\textcolor{keyword}{typename} G, \textcolor{keyword}{typename} Ret = \mbox{\hyperlink{namespaceutl_1_1meta_ac27f3e5f3ec42921d9f8a6bb85560cf1}{invoke\_t}}<G, T...>>
            \textcolor{keyword}{static} Ret \mbox{\hyperlink{structutl_1_1meta_1_1detail_1_1is__applicable__q___a6d258d626fb7889506d8d0c9c6ab14b1}{check}} (\textcolor{keywordtype}{int});    \textcolor{comment}{//< T.. can be passed to G}
         \textcolor{keyword}{template}<\textcolor{keyword}{typename}...>
            \textcolor{keyword}{static} nil\_ \mbox{\hyperlink{structutl_1_1meta_1_1detail_1_1is__applicable__q___a6d258d626fb7889506d8d0c9c6ab14b1}{check}} (...);   \textcolor{comment}{//< all other combinations}

         \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1detail_1_1is__applicable__q___a175161a76c46c8da1d170e329d17ce43}{type}} = \mbox{\hyperlink{group__type_ga39cc4e727a8faa5ea176f543e62c05c0}{if\_}} <
            \mbox{\hyperlink{group__integral_ga4dfaf054d891eb35d741662b077bbbd2}{not\_same\_}}<
               nil\_,
               decltype(check<F>(0))
            >, \mbox{\hyperlink{namespaceutl_1_1meta_ae9a5a8fbe8202785f059935af219fb97}{true\_}}, \mbox{\hyperlink{namespaceutl_1_1meta_a55511dbaa0adb605ce22dcec11f8d22d}{false\_}}
         >;
      \};

      \textcolor{keyword}{template}<\textcolor{keyword}{typename} T, \textcolor{keyword}{template} <T...> \textcolor{keyword}{class }F, T... Is>
      \textcolor{keyword}{struct }is\_applicable\_i\_ \{
         \textcolor{keyword}{template}<\textcolor{keyword}{typename} TT, \textcolor{keyword}{template}<TT...> \textcolor{keyword}{class }G, \textcolor{keyword}{typename} = G<Is...>>
            \textcolor{keyword}{static} \mbox{\hyperlink{namespaceutl_1_1meta_ae9a5a8fbe8202785f059935af219fb97}{true\_}} \mbox{\hyperlink{structutl_1_1meta_1_1detail_1_1is__applicable__i___ac03023fb86dba10d9dfbd0ba553daccd}{check}} (\textcolor{keywordtype}{int});  \textcolor{comment}{//< Is... can be passed to G}
         \textcolor{keyword}{template}<\textcolor{keyword}{typename} TT, \textcolor{keyword}{template}<TT...> \textcolor{keyword}{class }G>
            \textcolor{keyword}{static} \mbox{\hyperlink{namespaceutl_1_1meta_a55511dbaa0adb605ce22dcec11f8d22d}{false\_}} \mbox{\hyperlink{structutl_1_1meta_1_1detail_1_1is__applicable__i___ac03023fb86dba10d9dfbd0ba553daccd}{check}} (...); \textcolor{comment}{//< all other combinations}

         \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1detail_1_1is__applicable__i___ac512fdc9db578f9244b861f84c177ca7}{type}} = decltype(check<T, F>(0));
      \};
   \}

   \textcolor{keyword}{template}<\textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }F, \textcolor{keyword}{typename}... T>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a695a94a2bbe51b0d0eec9bf82214d094}{is\_applicable\_t}} = \mbox{\hyperlink{namespaceutl_1_1meta_aa5a37adba244ff4286f994111c4c02ea}{eval}}<
      detail::is\_applicable\_<F, T...>
   >;
   \textcolor{keyword}{template}<\textcolor{keyword}{typename} Q, \textcolor{keyword}{typename}... T>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a52c0afa73f63dc889e44cc6cc180f1f8}{is\_applicable\_qt}} = \mbox{\hyperlink{namespaceutl_1_1meta_aa5a37adba244ff4286f994111c4c02ea}{eval}} <
      detail::is\_applicable\_q\_ <Q, T...>
   >;

   \textcolor{keyword}{template} <\textcolor{keyword}{typename} T, \textcolor{keyword}{template}<T...> \textcolor{keyword}{class }F, T... Is>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_add602488265f07c7a3080355350cda70}{is\_applicable\_it}} = \mbox{\hyperlink{namespaceutl_1_1meta_aa5a37adba244ff4286f994111c4c02ea}{eval}}<
      detail::is\_applicable\_i\_<T, F, Is...>
   >;


   \textcolor{keyword}{namespace }detail \{
      \textcolor{keyword}{template}<\textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }F, \textcolor{keyword}{typename}... Ts>
      \textcolor{keyword}{struct }defer\_ \{
         \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1detail_1_1defer___ac8e2ede36472a15488ffdb49a6935be2}{type}} = F<Ts...>;
      \};

      \textcolor{keyword}{template}<\textcolor{keyword}{typename} T, \textcolor{keyword}{template}<T...> \textcolor{keyword}{class }F, T... Is>
      \textcolor{keyword}{struct }defer\_i\_ \{
         \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1detail_1_1defer__i___af8659048a08bb48bae5c0dc3f9595bf7}{type}} = F<Is...>;
      \};

   \}

   \textcolor{keyword}{template}<\textcolor{keyword}{template}<\textcolor{keyword}{class}...> \textcolor{keyword}{class }F, \textcolor{keyword}{class}... Ts>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a48f9a1220931596a9652351d2e7242be}{defer}} = \mbox{\hyperlink{group__type_ga39cc4e727a8faa5ea176f543e62c05c0}{if\_}}<
      detail::is\_applicable\_<F, Ts...>,
      detail::defer\_<F, Ts...>,
      nil\_  
   >;

   \textcolor{keyword}{template} <\textcolor{keyword}{typename} T, \textcolor{keyword}{template}<T...> \textcolor{keyword}{class }F, T... Is>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a01f183f337439e414184beedc9bcf9e3}{defer\_i}} = \mbox{\hyperlink{group__type_ga39cc4e727a8faa5ea176f543e62c05c0}{if\_}} <
      detail::is\_applicable\_i\_<T, F, Is...>,
      detail::defer\_i\_<T, F, Is...>,
      nil\_  
   >;


   \textcolor{keyword}{template} <\textcolor{keyword}{template} <\textcolor{keyword}{typename}...> \textcolor{keyword}{class }F>
   \textcolor{keyword}{struct }quote \{
      \textcolor{keyword}{template} <\textcolor{keyword}{typename}... Args>
      \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1quote_a7741173cf865291c89d374c2fac0d17e}{apply}} = \mbox{\hyperlink{namespaceutl_1_1meta_aa5a37adba244ff4286f994111c4c02ea}{eval}}<
         \mbox{\hyperlink{namespaceutl_1_1meta_a48f9a1220931596a9652351d2e7242be}{defer}}<F, Args...>    
      >;
   \};

   \textcolor{keyword}{template} <\textcolor{keyword}{typename} T, \textcolor{keyword}{template} <T...> \textcolor{keyword}{class }F>
   \textcolor{keyword}{struct }quote\_i \{
      \textcolor{comment}{// requires meta::Integral}
      \textcolor{keyword}{template} <\textcolor{keyword}{typename}... Ts>
      \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1quote__i_a32099809fbac1c620ad3993e8ab1b8c0}{apply}} = \mbox{\hyperlink{namespaceutl_1_1meta_aa5a37adba244ff4286f994111c4c02ea}{eval}}<
         \mbox{\hyperlink{namespaceutl_1_1meta_a01f183f337439e414184beedc9bcf9e3}{defer\_i}}<T, F, Ts::type::value...>  
      >;
   \};

   \textcolor{keyword}{namespace }detail \{
      \textcolor{keyword}{template} <\textcolor{keyword}{template} <\textcolor{keyword}{typename}...> \textcolor{keyword}{class}... Fns> \textcolor{keyword}{struct }compose\_f\_ \{\};

      \textcolor{comment}{// recursive call to all invokes}
      \textcolor{keyword}{template} <\textcolor{keyword}{template} <\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Fn0,
                \textcolor{keyword}{template} <\textcolor{keyword}{typename}...> \textcolor{keyword}{class}... Fns>
      \textcolor{keyword}{struct }compose\_f\_<Fn0, Fns...> \{
         \textcolor{keyword}{template} <\textcolor{keyword}{typename}... Args>
         \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a3f684549221fac60bc8c7979cb4b98f4}{apply}} = \mbox{\hyperlink{namespaceutl_1_1meta_a77630cd8adc01f7193f6cb834313d90f}{invoke}}<
            quote<Fn0>,
            \mbox{\hyperlink{namespaceutl_1_1meta_a77630cd8adc01f7193f6cb834313d90f}{invoke}}<compose\_f\_<Fns...>, Args...>
         >;
      \};
      \textcolor{comment}{// Termination specialization, finally pass the arguments}
      \textcolor{keyword}{template} <\textcolor{keyword}{template} <\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Fn0>
      \textcolor{keyword}{struct }compose\_f\_<Fn0> \{
         \textcolor{keyword}{template} <\textcolor{keyword}{typename} ...Args>
         \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a3f684549221fac60bc8c7979cb4b98f4}{apply}} = invoke<quote<Fn0>, Args...>;
      \};


      \textcolor{keyword}{template}<\textcolor{keyword}{typename} ...Fns> \textcolor{keyword}{struct }compose\_ \{\};

      \textcolor{comment}{// recursive call to all invokes}
      \textcolor{keyword}{template}<\textcolor{keyword}{typename} Fn0, \textcolor{keyword}{typename} ...Fns>
      \textcolor{keyword}{struct }compose\_<Fn0, Fns...> \{
         \textcolor{keyword}{template} <\textcolor{keyword}{typename} ...Args>
         \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a3f684549221fac60bc8c7979cb4b98f4}{apply}} = \mbox{\hyperlink{namespaceutl_1_1meta_a77630cd8adc01f7193f6cb834313d90f}{invoke}}<
               Fn0,
               \mbox{\hyperlink{namespaceutl_1_1meta_a77630cd8adc01f7193f6cb834313d90f}{invoke}}<compose\_<Fns...>, Args...>
         >;
      \};
      \textcolor{comment}{// Termination specialization, finally pass the arguments}
      \textcolor{keyword}{template}<\textcolor{keyword}{typename} Fn0>
      \textcolor{keyword}{struct }compose\_<Fn0> \{
         \textcolor{keyword}{template} <\textcolor{keyword}{typename}... Args>
         \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a3f684549221fac60bc8c7979cb4b98f4}{apply}} = \mbox{\hyperlink{namespaceutl_1_1meta_a77630cd8adc01f7193f6cb834313d90f}{invoke}}<Fn0, Args...>;
      \};
   \}

   \textcolor{keyword}{template} <\textcolor{keyword}{typename}... Fns>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a4f0c06cabe66bc73b703eb8509c7bb07}{compose}} = detail::compose\_<Fns...>;

   \textcolor{keyword}{template} <\textcolor{keyword}{template} <\textcolor{keyword}{typename}...> \textcolor{keyword}{class}... Fns>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a729294327829b3068632da1235dc3090}{compose\_f}} = detail::compose\_f\_<Fns...>;

   \textcolor{keyword}{template}<\textcolor{keyword}{typename} Fn, \textcolor{keyword}{typename}... Ts>
   \textcolor{keyword}{struct }bind\_front \{
       \textcolor{keyword}{template}<\textcolor{keyword}{typename}... Us>
       \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1bind__front_a4247cb2b0a19e3168161dead529c532c}{apply}} = \mbox{\hyperlink{namespaceutl_1_1meta_a77630cd8adc01f7193f6cb834313d90f}{invoke}}<Fn, Ts..., Us...>;
   \};

   \textcolor{keyword}{template}<\textcolor{keyword}{typename} Fn, \textcolor{keyword}{typename}... Ts>
   \textcolor{keyword}{struct }bind\_back \{
       \textcolor{keyword}{template}<\textcolor{keyword}{typename}... Us>
       \textcolor{keyword}{using} \mbox{\hyperlink{structutl_1_1meta_1_1bind__back_a2f8a5ad9fd3b9e5ed79ace2c18d1ec9a}{apply}} = \mbox{\hyperlink{namespaceutl_1_1meta_a77630cd8adc01f7193f6cb834313d90f}{invoke}}<Fn, Us..., Ts...>;
   \};


   \textcolor{comment}{/*}
\textcolor{comment}{    * ========== meta:: predicates ============}
\textcolor{comment}{    */}
   \textcolor{keyword}{template} <\textcolor{keyword}{typename} T1>
   \textcolor{keyword}{struct }same\_as \{
      \textcolor{keyword}{template} <\textcolor{keyword}{typename} T2>
      \textcolor{keyword}{struct }\mbox{\hyperlink{namespaceutl_1_1meta_a3f684549221fac60bc8c7979cb4b98f4}{apply}} : same\_<T1, T2> \{ \};
   \};

   \textcolor{keyword}{template} <\textcolor{keyword}{typename} T1>
   \textcolor{keyword}{struct }not\_same\_as \{
      \textcolor{keyword}{template} <\textcolor{keyword}{typename} T2>
      \textcolor{keyword}{struct }\mbox{\hyperlink{namespaceutl_1_1meta_a3f684549221fac60bc8c7979cb4b98f4}{apply}} : \mbox{\hyperlink{group__integral_ga4dfaf054d891eb35d741662b077bbbd2}{not\_same\_}}<T1, T2> \{ \};
   \};

\}\}


\textcolor{preprocessor}{#endif }\textcolor{comment}{/* \_\_utl\_meta\_invoke\_h\_\_ */}\textcolor{preprocessor}{}
\end{DoxyCodeInclude}
 