\section{/var/www/mlpack.ratml.\+org/mlpack.org/\+\_\+src/mlpack-\/3.3.0/src/mlpack/core/util/sfinae\+\_\+utility.hpp File Reference}
\label{sfinae__utility_8hpp}\index{/var/www/mlpack.\+ratml.\+org/mlpack.\+org/\+\_\+src/mlpack-\/3.\+3.\+0/src/mlpack/core/util/sfinae\+\_\+utility.\+hpp@{/var/www/mlpack.\+ratml.\+org/mlpack.\+org/\+\_\+src/mlpack-\/3.\+3.\+0/src/mlpack/core/util/sfinae\+\_\+utility.\+hpp}}
Include dependency graph for sfinae\+\_\+utility.\+hpp\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=178pt]{sfinae__utility_8hpp__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]{sfinae__utility_8hpp__dep__incl}
\end{center}
\end{figure}
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ Method\+Form\+Detector$<$ Class, Method\+Form, Additional\+Args\+Count $>$}
\item 
struct \textbf{ Method\+Form\+Detector$<$ Class, Method\+Form, 0 $>$}
\item 
struct \textbf{ Method\+Form\+Detector$<$ Class, Method\+Form, 1 $>$}
\item 
struct \textbf{ Method\+Form\+Detector$<$ Class, Method\+Form, 2 $>$}
\item 
struct \textbf{ Method\+Form\+Detector$<$ Class, Method\+Form, 3 $>$}
\item 
struct \textbf{ Method\+Form\+Detector$<$ Class, Method\+Form, 4 $>$}
\item 
struct \textbf{ Method\+Form\+Detector$<$ Class, Method\+Form, 5 $>$}
\item 
struct \textbf{ Method\+Form\+Detector$<$ Class, Method\+Form, 6 $>$}
\item 
struct \textbf{ Method\+Form\+Detector$<$ Class, Method\+Form, 7 $>$}
\item 
struct \textbf{ Sig\+Check$<$ U, U $>$}
\begin{DoxyCompactList}\small\item\em Utility struct for checking signatures. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Namespaces}
\begin{DoxyCompactItemize}
\item 
 \textbf{ mlpack}
\begin{DoxyCompactList}\small\item\em strip\+\_\+type.\+hpp \end{DoxyCompactList}\item 
 \textbf{ mlpack\+::sfinae}
\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ H\+A\+S\+\_\+\+A\+N\+Y\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}(F\+U\+NC,  N\+A\+ME)
\begin{DoxyCompactList}\small\item\em Constructs a template structure, which will define a boolean static variable, to true, if the passed template parameter, has a member function with the specified name. \end{DoxyCompactList}\item 
\#define \textbf{ H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}(M\+E\+T\+H\+OD,  N\+A\+ME)~\textbf{ H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M\+\_\+\+B\+A\+SE}(\textbf{ S\+I\+N\+G\+L\+E\+\_\+\+A\+RG}(M\+E\+T\+H\+OD), \textbf{ S\+I\+N\+G\+L\+E\+\_\+\+A\+RG}(N\+A\+ME), 0)
\begin{DoxyCompactList}\small\item\em H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM generates a template that allows a compile time check whether a given class has a method of the requested form. \end{DoxyCompactList}\item 
\#define \textbf{ H\+A\+S\+\_\+\+M\+E\+M\+\_\+\+F\+U\+NC}(F\+U\+NC,  N\+A\+ME)
\item 
\#define \textbf{ H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}(M\+E\+T\+H\+OD,  N\+A\+ME)~\textbf{ H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M\+\_\+\+B\+A\+SE}(\textbf{ S\+I\+N\+G\+L\+E\+\_\+\+A\+RG}(M\+E\+T\+H\+OD), \textbf{ S\+I\+N\+G\+L\+E\+\_\+\+A\+RG}(N\+A\+ME), 7)
\begin{DoxyCompactList}\small\item\em H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM generates a template that allows a compile time check for whether a given class has a method of the requested form. \end{DoxyCompactList}\item 
\#define \textbf{ H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M\+\_\+\+B\+A\+SE}(M\+E\+T\+H\+OD,  N\+A\+ME,  M\+A\+XN)
\begin{DoxyCompactList}\small\item\em Base macro for \doxyref{H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M()}{p.}{sfinae__utility_8hpp_abf5173ce974543d1692eded938137785} and \doxyref{H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M()}{p.}{sfinae__utility_8hpp_a99c43679f4f968143352345b3b00a204} macros. \end{DoxyCompactList}\item 
\#define \textbf{ S\+I\+N\+G\+L\+E\+\_\+\+A\+RG}(...)~\+\_\+\+\_\+\+V\+A\+\_\+\+A\+R\+G\+S\+\_\+\+\_\+
\end{DoxyCompactItemize}


\subsection{Detailed Description}
\begin{DoxyAuthor}{Author}
Trironk Kiatkungwanglai, Kirill Mishchenko
\end{DoxyAuthor}
This file contains macro utilities for the S\+F\+I\+N\+AE Paradigm. These utilities determine if classes passed in as template parameters contain members at compile time, which is useful for changing functionality depending on what operations an object is capable of performing.

mlpack is free software; you may redistribute it and/or modify it under the terms of the 3-\/clause B\+SD license. You should have received a copy of the 3-\/clause B\+SD license along with mlpack. If not, see {\tt http\+://www.\+opensource.\+org/licenses/\+B\+S\+D-\/3-\/\+Clause} for more information. 

\subsection{Macro Definition Documentation}
\mbox{\label{sfinae__utility_8hpp_a5d2647cae727e305ee03c69f7d81a24d}} 
\index{sfinae\+\_\+utility.\+hpp@{sfinae\+\_\+utility.\+hpp}!H\+A\+S\+\_\+\+A\+N\+Y\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM@{H\+A\+S\+\_\+\+A\+N\+Y\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}}
\index{H\+A\+S\+\_\+\+A\+N\+Y\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM@{H\+A\+S\+\_\+\+A\+N\+Y\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}!sfinae\+\_\+utility.\+hpp@{sfinae\+\_\+utility.\+hpp}}
\subsubsection{H\+A\+S\+\_\+\+A\+N\+Y\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}
{\footnotesize\ttfamily \#define H\+A\+S\+\_\+\+A\+N\+Y\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM(\begin{DoxyParamCaption}\item[{}]{F\+U\+NC,  }\item[{}]{N\+A\+ME }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}
\textcolor{keyword}{template} <\textcolor{keyword}{typename} T>                                                        \(\backslash\)
struct NAME                                                                  \(\backslash\)
\{                                                                            \(\backslash\)
  template <typename Q = T>                                                  \(\backslash\)
  static typename                                                            \(\backslash\)
  std::enable\_if<std::is\_member\_function\_pointer<decltype(&Q::FUNC)>::value, \(\backslash\)
                 int>::type                                                  \(\backslash\)
  f(\textcolor{keywordtype}{int}) \{ \textcolor{keywordflow}{return} 1;\}                                                      \(\backslash\)
                                                                             \(\backslash\)
  template <typename Q = T>                                                  \(\backslash\)
  static \textcolor{keywordtype}{char} f(\textcolor{keywordtype}{char}) \{ \textcolor{keywordflow}{return} 0; \}                                        \(\backslash\)
                                                                             \(\backslash\)
  static \textcolor{keyword}{const} \textcolor{keywordtype}{bool} value = \textcolor{keyword}{sizeof}(f<T>(0)) != \textcolor{keyword}{sizeof}(char);                 \(\backslash\)
\};
\end{DoxyCode}


Constructs a template structure, which will define a boolean static variable, to true, if the passed template parameter, has a member function with the specified name. 

The check does not care about the signature or the function parameters.


\begin{DoxyParams}{Parameters}
{\em F\+U\+NC} & the name of the function, whose existence is to be detected \\
\hline
{\em N\+A\+ME} & the name of the structure that will be generated\\
\hline
\end{DoxyParams}
Use this like\+: N\+A\+M\+E$<$\+Class\+Name$>$\+::value to check for the existence of the function in the given class name. This can also be used in conjunction with std\+::enable\+\_\+if. 

Definition at line 201 of file sfinae\+\_\+utility.\+hpp.

\mbox{\label{sfinae__utility_8hpp_a99c43679f4f968143352345b3b00a204}} 
\index{sfinae\+\_\+utility.\+hpp@{sfinae\+\_\+utility.\+hpp}!H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM@{H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}}
\index{H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM@{H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}!sfinae\+\_\+utility.\+hpp@{sfinae\+\_\+utility.\+hpp}}
\subsubsection{H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}
{\footnotesize\ttfamily \#define H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM(\begin{DoxyParamCaption}\item[{}]{M\+E\+T\+H\+OD,  }\item[{}]{N\+A\+ME }\end{DoxyParamCaption})~\textbf{ H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M\+\_\+\+B\+A\+SE}(\textbf{ S\+I\+N\+G\+L\+E\+\_\+\+A\+RG}(M\+E\+T\+H\+OD), \textbf{ S\+I\+N\+G\+L\+E\+\_\+\+A\+RG}(N\+A\+ME), 0)}



H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM generates a template that allows a compile time check whether a given class has a method of the requested form. 

For example, for the following class

class A \{ public\+: ... Train(const arma\+::mat\&, const arma\+::\+Row$<$size\+\_\+t$>$\&); ... \};

and the following form of Train methods

template$<$typename Class$>$ using Train\+Form = void(\+Class\+::$\ast$)(const arma\+::mat\&, const arma\+::\+Row$<$size\+\_\+t$>$\&);

we can check whether the class A has a Train method of the specified form\+:

\doxyref{H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M(\+Train, Has\+Train)}{p.}{sfinae__utility_8hpp_abf5173ce974543d1692eded938137785}; static\+\_\+assert(Has\+Train$<$\+A, Train\+From$>$\+::value, \char`\"{}value should be true\char`\"{});

The class generated by this will only return true values if the signature matches exactly.


\begin{DoxyParams}{Parameters}
{\em M\+E\+T\+H\+OD} & The name of the method to check for. \\
\hline
{\em N\+A\+ME} & The name of the struct to construct. \\
\hline
{\em M\+A\+XN} & The maximum number of additional arguments. \\
\hline
\end{DoxyParams}


Definition at line 287 of file sfinae\+\_\+utility.\+hpp.

\mbox{\label{sfinae__utility_8hpp_a00819f02259866fea01a6adf725c7ecf}} 
\index{sfinae\+\_\+utility.\+hpp@{sfinae\+\_\+utility.\+hpp}!H\+A\+S\+\_\+\+M\+E\+M\+\_\+\+F\+U\+NC@{H\+A\+S\+\_\+\+M\+E\+M\+\_\+\+F\+U\+NC}}
\index{H\+A\+S\+\_\+\+M\+E\+M\+\_\+\+F\+U\+NC@{H\+A\+S\+\_\+\+M\+E\+M\+\_\+\+F\+U\+NC}!sfinae\+\_\+utility.\+hpp@{sfinae\+\_\+utility.\+hpp}}
\subsubsection{H\+A\+S\+\_\+\+M\+E\+M\+\_\+\+F\+U\+NC}
{\footnotesize\ttfamily \#define H\+A\+S\+\_\+\+M\+E\+M\+\_\+\+F\+U\+NC(\begin{DoxyParamCaption}\item[{}]{F\+U\+NC,  }\item[{}]{N\+A\+ME }\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}
\textcolor{keyword}{template}<\textcolor{keyword}{typename} T, \textcolor{keyword}{typename} sig, \textcolor{keyword}{typename} = std::true\_type>                  \(\backslash\)
struct NAME : std::false\_type \{\};                                              \(\backslash\)
                                                                               \(\backslash\)
template<typename T, typename sig>                                             \(\backslash\)
struct NAME                                                                    \(\backslash\)
<                                                                              \(\backslash\)
  T,                                                                           \(\backslash\)
  sig,                                                                         \(\backslash\)
  std::integral\_constant<bool, mlpack::sfinae::SigCheck<sig, &T::FUNC>::value> \(\backslash\)
> : std::true\_type \{\};
\end{DoxyCode}


Definition at line 128 of file sfinae\+\_\+utility.\+hpp.

\mbox{\label{sfinae__utility_8hpp_abf5173ce974543d1692eded938137785}} 
\index{sfinae\+\_\+utility.\+hpp@{sfinae\+\_\+utility.\+hpp}!H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM@{H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}}
\index{H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM@{H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}!sfinae\+\_\+utility.\+hpp@{sfinae\+\_\+utility.\+hpp}}
\subsubsection{H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM}
{\footnotesize\ttfamily \#define H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM(\begin{DoxyParamCaption}\item[{}]{M\+E\+T\+H\+OD,  }\item[{}]{N\+A\+ME }\end{DoxyParamCaption})~\textbf{ H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M\+\_\+\+B\+A\+SE}(\textbf{ S\+I\+N\+G\+L\+E\+\_\+\+A\+RG}(M\+E\+T\+H\+OD), \textbf{ S\+I\+N\+G\+L\+E\+\_\+\+A\+RG}(N\+A\+ME), 7)}



H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+RM generates a template that allows a compile time check for whether a given class has a method of the requested form. 

For example, for the following class

class A \{ public\+: ... Train(const arma\+::mat\&, const arma\+::\+Row$<$size\+\_\+t$>$\&, double); ... \};

and the following form of Train methods

template$<$typename Class, typename...\+Ts$>$ using Train\+Form = void(\+Class\+::$\ast$)(const arma\+::mat\&, const arma\+::\+Row$<$size\+\_\+t$>$\&, Ts...);

we can check whether the class A has a Train method of the specified form\+:

\doxyref{H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M(\+Train, Has\+Train)}{p.}{sfinae__utility_8hpp_abf5173ce974543d1692eded938137785}; static\+\_\+assert(Has\+Train$<$\+A, Train\+From$>$\+::value, \char`\"{}value should be true\char`\"{});

The class generated by this will also return true values if the given class has a method that also has extra parameters.


\begin{DoxyParams}{Parameters}
{\em M\+E\+T\+H\+OD} & The name of the method to check for. \\
\hline
{\em N\+A\+ME} & The name of the struct to construct. \\
\hline
{\em M\+A\+XN} & The maximum number of additional arguments. \\
\hline
\end{DoxyParams}


Definition at line 253 of file sfinae\+\_\+utility.\+hpp.

\mbox{\label{sfinae__utility_8hpp_ac21bd72c270768aff7a2657f26876e21}} 
\index{sfinae\+\_\+utility.\+hpp@{sfinae\+\_\+utility.\+hpp}!H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M\+\_\+\+B\+A\+SE@{H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M\+\_\+\+B\+A\+SE}}
\index{H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M\+\_\+\+B\+A\+SE@{H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M\+\_\+\+B\+A\+SE}!sfinae\+\_\+utility.\+hpp@{sfinae\+\_\+utility.\+hpp}}
\subsubsection{H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M\+\_\+\+B\+A\+SE}
{\footnotesize\ttfamily \#define H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M\+\_\+\+B\+A\+SE(\begin{DoxyParamCaption}\item[{}]{M\+E\+T\+H\+OD,  }\item[{}]{N\+A\+ME,  }\item[{}]{M\+A\+XN }\end{DoxyParamCaption})}



Base macro for \doxyref{H\+A\+S\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M()}{p.}{sfinae__utility_8hpp_abf5173ce974543d1692eded938137785} and \doxyref{H\+A\+S\+\_\+\+E\+X\+A\+C\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+M()}{p.}{sfinae__utility_8hpp_a99c43679f4f968143352345b3b00a204} macros. 



Definition at line 143 of file sfinae\+\_\+utility.\+hpp.

\mbox{\label{sfinae__utility_8hpp_afa8624400132dca5f52f93deec70706b}} 
\index{sfinae\+\_\+utility.\+hpp@{sfinae\+\_\+utility.\+hpp}!S\+I\+N\+G\+L\+E\+\_\+\+A\+RG@{S\+I\+N\+G\+L\+E\+\_\+\+A\+RG}}
\index{S\+I\+N\+G\+L\+E\+\_\+\+A\+RG@{S\+I\+N\+G\+L\+E\+\_\+\+A\+RG}!sfinae\+\_\+utility.\+hpp@{sfinae\+\_\+utility.\+hpp}}
\subsubsection{S\+I\+N\+G\+L\+E\+\_\+\+A\+RG}
{\footnotesize\ttfamily \#define S\+I\+N\+G\+L\+E\+\_\+\+A\+RG(\begin{DoxyParamCaption}\item[{}]{... }\end{DoxyParamCaption})~\+\_\+\+\_\+\+V\+A\+\_\+\+A\+R\+G\+S\+\_\+\+\_\+}



Definition at line 220 of file sfinae\+\_\+utility.\+hpp.

