#ifndef VCZH_FUNCTION
#define VCZH_FUNCTION
#include <memory.h>
#include "Basic.h"
#include "Pointer.h"
namespace
{
template
<
typename
>
class
;
namespace
{
template
<
typename
>
struct
{
};
template
<
typename
>
struct
FunctionObjectRetriveType
{
typedef
typename
<
decltype
(&
::
operator
())>::Type
;
typedef
typename
<
decltype
(&
::
operator
())>::FunctionType
;
typedef
typename
<
decltype
(&
::
operator
())>::ResultType
;
typedef
typename
<
decltype
(&
::
operator
())>::ParameterTypes
;
};
template
<
typename
,
typename
,
typename
...
>
struct
<
(
__thiscall
::*)(
...)
const
>
{
typedef
<
(
...)>
;
typedef
(
)(
...);
typedef
;
typedef
<
...>
;
};
template
<
typename
,
typename
,
typename
...
>
struct
<
(
__thiscall
::*)(
...)>
{
typedef
<
(
...)>
;
typedef
(
)(
...);
typedef
;
typedef
<
...>
;
};
template
<
typename
,
typename
...
>
struct
FunctionObjectRetriveType
<
(*)(
...)>
{
typedef
<
(
...)>
;
typedef
(
)(
...);
typedef
;
typedef
<
...>
;
};
}
namespace
{
template
<
typename
,
typename
...
>
class
:
public
{
public
:
virtual
(
&& ...
) =
0
;
};
template
<
typename
,
typename
...
>
class
:
public
<
,
...>
{
protected
:
(*
)(
...
);
public
:
(
(*
)(
...))
:function(
)
{
}
(
&& ...
)
override
{
return
(
<
>(
)...);
}
};
template
<
typename
,
typename
,
typename
...
>
class
:
public
<
,
...>
{
protected
:
*
;
(
::*
)(
...
);
public
:
(
*
,
(
::*
)(
...
))
:sender(
)
,function(
)
{
}
(
&& ...
)
override
{
return
(
->*
)(
<
>(
)...);
}
};
template
<
typename
,
typename
,
typename
...
>
class
:
public
<
,
...>
{
protected
:
;
public
:
(
const
&
)
:function(
)
{
}
(
&&
)
:function(
(
))
{
}
(
&& ...
)
override
{
return
(
<
>(
)...);
}
};
template
<
typename
,
typename
...
>
class
<
,
void
,
...> :
public
<
void
,
...>
{
protected
:
;
public
:
(
const
&
)
:function(
)
{
}
(
&&
)
:function(
(
))
{
}
void
(
&& ...
)
override
{
(
<
>(
)...);
}
};
}
template
<
typename
,
typename
...
>
class
<
(
...)> :
public
{
protected
:
<
internal_invokers
::
<
,
...>>
;
template
<
typename
,
typename
...
>
static
bool
(
const
<
(
...)>&
)
{
return
!
;
}
template
<
typename
,
typename
...
>
static
bool
(
<
(
...)>&
)
{
return
!
;
}
template
<
typename
>
static
bool
(
&&)
{
return
false
;
}
public
:
typedef
(
...);
typedef
;
() =
default
;
(
const
<
(
...)>&
) =
default
;
(
<
(
...)>&&
) =
default
;
(
(*
)(
...))
{
new
internal_invokers
::
<
,
...>(
);
}
template
<
typename
>
(
*
,
(
::*
)(
...))
{
new
internal_invokers
::
<
,
,
...>(
,
);
}
template
<
typename
,
typename
=
typename
<
void
,
typename
<
decltype
(
<
>()(
<
>()...)),
>::
>::
>
(
&&
)
{
if
(!
(
))
{
new
internal_invokers
::
<
typename
<
>::
,
,
...>(
<
&&>(
));
}
}
(
...
)
const
{
return
(
<
>(
)...);
}
<
(
...)>&
(
const
<
(
...)>&
)
{
.
;
return
*
this
;
}
<
(
...)>&
(
const
<
(
...)>&&
)
{
(
.
);
return
*
this
;
}
bool
(
const
<
(
...)>&
)
const
{
return
.
;
}
bool
(
const
<
(
...)>&
)
const
{
return
.
;
}
bool
()
const
{
return
;
}
};
namespace
{
template
<
typename
>
typename
<
decltype
(&
::
operator
())>::
(
)
{
return
;
}
template
<
typename
>
typename
FunctionObjectRetriveType
<
>::
(
)
{
return
;
}
#define LAMBDA vl::function_lambda::Lambda
#define FUNCTION vl::function_lambda::ConvertToFunction
#define FUNCTION_TYPE(T) typename vl::function_lambda::FunctionObjectRetriveType<T>::Type
#define FUNCTION_RESULT_TYPE(T) typename vl::function_lambda::FunctionObjectRetriveType<T>::ResultType
}
namespace
{
template
<
typename
>
struct
{
};
template
<
typename
>
struct
{
typedef
const
&
;};
template
<
typename
>
struct
<
&>{
typedef
&
;};
template
<
typename
>
struct
<
const
>{
typedef
const
&
;};
template
<
typename
>
struct
<
const
&>{
typedef
const
&
;};
template
<
typename
,
typename
,
typename
...
>
struct
<
(
,
...)>
{
typedef
(
,
...);
typedef
(
...);
typedef
;
class
:
public
{
protected
:
<
>
;
;
public
:
(
const
<
>&
,
)
:target(
)
,firstArgument(
<
>(
))
{
}
(
...
)
const
{
return
,
...);
}
};
class
:
public
{
protected
:
<
>
;
public
:
(
const
<
>&
)
:target(
)
{
}
<
>
(
)
const
{
return
(
,
);
}
};
};
}
template
<
typename
>
<
<
typename
function_binding
::
<
>::
>(
typename
function_binding
::
<
>::
)>
(
*
)
{
return
typename
function_binding
::
<
>::
(
);
}
template
<
typename
>
<
<
typename
function_binding
::
<
>::
>(
typename
function_binding
::
<
>::
)>
(
const
<
>&
)
{
return
typename
function_binding
::
<
>::
(
);
}
}
#endif