.TH "/var/www/mlpack.ratml.org/mlpack.org/_src/mlpack-git/src/mlpack/core/util/sfinae_utility.hpp" 3 "Mon Aug 31 2020" "Version 3.3.2" "mlpack" \" -*- nroff -*-
.ad l
.nh
.SH NAME
/var/www/mlpack.ratml.org/mlpack.org/_src/mlpack-git/src/mlpack/core/util/sfinae_utility.hpp
.SH SYNOPSIS
.br
.PP
.SS "Classes"

.in +1c
.ti -1c
.RI "struct \fBMethodFormDetector< Class, MethodForm, AdditionalArgsCount >\fP"
.br
.ti -1c
.RI "struct \fBMethodFormDetector< Class, MethodForm, 0 >\fP"
.br
.ti -1c
.RI "struct \fBMethodFormDetector< Class, MethodForm, 1 >\fP"
.br
.ti -1c
.RI "struct \fBMethodFormDetector< Class, MethodForm, 2 >\fP"
.br
.ti -1c
.RI "struct \fBMethodFormDetector< Class, MethodForm, 3 >\fP"
.br
.ti -1c
.RI "struct \fBMethodFormDetector< Class, MethodForm, 4 >\fP"
.br
.ti -1c
.RI "struct \fBMethodFormDetector< Class, MethodForm, 5 >\fP"
.br
.ti -1c
.RI "struct \fBMethodFormDetector< Class, MethodForm, 6 >\fP"
.br
.ti -1c
.RI "struct \fBMethodFormDetector< Class, MethodForm, 7 >\fP"
.br
.ti -1c
.RI "struct \fBSigCheck< U, U >\fP"
.br
.RI "Utility struct for checking signatures\&. "
.in -1c
.SS "Namespaces"

.in +1c
.ti -1c
.RI " \fBmlpack\fP"
.br
.RI "Linear algebra utility functions, generally performed on matrices or vectors\&. "
.ti -1c
.RI " \fBmlpack::sfinae\fP"
.br
.in -1c
.SS "Macros"

.in +1c
.ti -1c
.RI "#define \fBHAS_ANY_METHOD_FORM\fP(FUNC,  NAME)"
.br
.RI "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\&. "
.ti -1c
.RI "#define \fBHAS_EXACT_METHOD_FORM\fP(METHOD,  NAME)   \fBHAS_METHOD_FORM_BASE\fP(\fBSINGLE_ARG\fP(METHOD), \fBSINGLE_ARG\fP(NAME), 0)"
.br
.RI "HAS_EXACT_METHOD_FORM generates a template that allows a compile time check whether a given class has a method of the requested form\&. "
.ti -1c
.RI "#define \fBHAS_MEM_FUNC\fP(FUNC,  NAME)"
.br
.ti -1c
.RI "#define \fBHAS_METHOD_FORM\fP(METHOD,  NAME)   \fBHAS_METHOD_FORM_BASE\fP(\fBSINGLE_ARG\fP(METHOD), \fBSINGLE_ARG\fP(NAME), 7)"
.br
.RI "HAS_METHOD_FORM generates a template that allows a compile time check for whether a given class has a method of the requested form\&. "
.ti -1c
.RI "#define \fBHAS_METHOD_FORM_BASE\fP(METHOD,  NAME,  MAXN)"
.br
.RI "Base macro for \fBHAS_METHOD_FORM()\fP and \fBHAS_EXACT_METHOD_FORM()\fP macros\&. "
.ti -1c
.RI "#define \fBSINGLE_ARG\fP(\&.\&.\&.)   __VA_ARGS__"
.br
.in -1c
.SH "Detailed Description"
.PP 

.PP
\fBAuthor:\fP
.RS 4
Trironk Kiatkungwanglai, Kirill Mishchenko
.RE
.PP
This file contains macro utilities for the SFINAE 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\&.
.PP
mlpack is free software; you may redistribute it and/or modify it under the terms of the 3-clause BSD license\&. You should have received a copy of the 3-clause BSD license along with mlpack\&. If not, see http://www.opensource.org/licenses/BSD-3-Clause for more information\&. 
.PP
Definition in file \fBsfinae_utility\&.hpp\fP\&.
.SH "Macro Definition Documentation"
.PP 
.SS "#define HAS_ANY_METHOD_FORM(FUNC, NAME)"
\fBValue:\fP
.PP
.nf
template <typename T>                                                        \
struct NAME                                                                  \
{                                                                            \
  template <typename Q = T>                                                  \
  static typename                                                            \
  std::enable_if<std::is_member_function_pointer<decltype(&Q::FUNC)>::value, \
                 int>::type                                                  \
  f(int) { return 1;}                                                      \
                                                                             \
  template <typename Q = T>                                                  \
  static char f(char) { return 0; }                                        \
                                                                             \
  static const bool value = sizeof(f<T>(0)) != sizeof(char);                 \
};
.fi
.PP
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\&.
.PP
\fBParameters:\fP
.RS 4
\fIFUNC\fP the name of the function, whose existence is to be detected 
.br
\fINAME\fP the name of the structure that will be generated
.RE
.PP
Use this like: NAME<ClassName>::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\&. 
.PP
Definition at line 201 of file sfinae_utility\&.hpp\&.
.SS "#define HAS_EXACT_METHOD_FORM(METHOD, NAME)   \fBHAS_METHOD_FORM_BASE\fP(\fBSINGLE_ARG\fP(METHOD), \fBSINGLE_ARG\fP(NAME), 0)"

.PP
HAS_EXACT_METHOD_FORM 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
.PP
class A { public: \&.\&.\&. Train(const arma::mat&, const arma::Row<size_t>&); \&.\&.\&. };
.PP
and the following form of Train methods
.PP
template<typename Class> using TrainForm = void(Class::*)(const arma::mat&, const arma::Row<size_t>&);
.PP
we can check whether the class A has a Train method of the specified form:
.PP
\fBHAS_METHOD_FORM(Train, HasTrain)\fP; static_assert(HasTrain<A, TrainFrom>::value, 'value should be true');
.PP
The class generated by this will only return true values if the signature matches exactly\&.
.PP
\fBParameters:\fP
.RS 4
\fIMETHOD\fP The name of the method to check for\&. 
.br
\fINAME\fP The name of the struct to construct\&. 
.RE
.PP

.PP
Definition at line 285 of file sfinae_utility\&.hpp\&.
.SS "#define HAS_MEM_FUNC(FUNC, NAME)"
\fBValue:\fP
.PP
.nf
template<typename T, typename sig, typename = std::true_type>                  \
struct NAME : std::false_type {};                                              \
                                                                               \
template<typename T, typename sig>                                             \
struct NAME                                                                    \
<                                                                              \
  T,                                                                           \
  sig,                                                                         \
  std::integral_constant<bool, mlpack::sfinae::SigCheck<sig, &T::FUNC>::value> \
> : std::true_type {};
.fi
.PP
Definition at line 128 of file sfinae_utility\&.hpp\&.
.SS "#define HAS_METHOD_FORM(METHOD, NAME)   \fBHAS_METHOD_FORM_BASE\fP(\fBSINGLE_ARG\fP(METHOD), \fBSINGLE_ARG\fP(NAME), 7)"

.PP
HAS_METHOD_FORM 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
.PP
class A { public: \&.\&.\&. Train(const arma::mat&, const arma::Row<size_t>&, double); \&.\&.\&. };
.PP
and the following form of Train methods
.PP
template<typename Class, typename\&.\&.\&.Ts> using TrainForm = void(Class::*)(const arma::mat&, const arma::Row<size_t>&, Ts\&.\&.\&.);
.PP
we can check whether the class A has a Train method of the specified form:
.PP
\fBHAS_METHOD_FORM(Train, HasTrain)\fP; static_assert(HasTrain<A, TrainFrom>::value, 'value should be true');
.PP
The class generated by this will also return true values if the given class has a method that also has extra parameters\&.
.PP
\fBParameters:\fP
.RS 4
\fIMETHOD\fP The name of the method to check for\&. 
.br
\fINAME\fP The name of the struct to construct\&. 
.RE
.PP

.PP
Definition at line 252 of file sfinae_utility\&.hpp\&.
.SS "#define HAS_METHOD_FORM_BASE(METHOD, NAME, MAXN)"

.PP
Base macro for \fBHAS_METHOD_FORM()\fP and \fBHAS_EXACT_METHOD_FORM()\fP macros\&. 
.PP
Definition at line 143 of file sfinae_utility\&.hpp\&.
.SS "#define SINGLE_ARG( \&.\&.\&.)   __VA_ARGS__"

.PP
Definition at line 220 of file sfinae_utility\&.hpp\&.
.SH "Author"
.PP 
Generated automatically by Doxygen for mlpack from the source code\&.
