mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-07 01:06:54 +08:00
Callable traits constexpr
This commit is contained in:
parent
ac8f876347
commit
b810e4f7d9
@ -25,10 +25,10 @@ namespace chaiscript {
|
|||||||
template<typename Ret, typename Class, typename ... Param>
|
template<typename Ret, typename Class, typename ... Param>
|
||||||
struct Const_Caller
|
struct Const_Caller
|
||||||
{
|
{
|
||||||
explicit Const_Caller(Ret (Class::*t_func)(Param...) const) : m_func(t_func) {}
|
constexpr explicit Const_Caller(Ret (Class::*t_func)(Param...) const) : m_func(t_func) {}
|
||||||
|
|
||||||
template<typename ... Inner>
|
template<typename ... Inner>
|
||||||
Ret operator()(const Class &o, Inner&& ... inner) const {
|
constexpr Ret operator()(const Class &o, Inner&& ... inner) const {
|
||||||
return (o.*m_func)(std::forward<Inner>(inner)...);
|
return (o.*m_func)(std::forward<Inner>(inner)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,10 +38,10 @@ namespace chaiscript {
|
|||||||
template<typename Ret, typename ... Param>
|
template<typename Ret, typename ... Param>
|
||||||
struct Fun_Caller
|
struct Fun_Caller
|
||||||
{
|
{
|
||||||
explicit Fun_Caller(Ret( * t_func)(Param...) ) : m_func(t_func) {}
|
constexpr explicit Fun_Caller(Ret( * t_func)(Param...) ) : m_func(t_func) {}
|
||||||
|
|
||||||
template<typename ... Inner>
|
template<typename ... Inner>
|
||||||
Ret operator()(Inner&& ... inner) const {
|
constexpr Ret operator()(Inner&& ... inner) const {
|
||||||
return (m_func)(std::forward<Inner>(inner)...);
|
return (m_func)(std::forward<Inner>(inner)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,10 +51,10 @@ namespace chaiscript {
|
|||||||
template<typename Ret, typename Class, typename ... Param>
|
template<typename Ret, typename Class, typename ... Param>
|
||||||
struct Caller
|
struct Caller
|
||||||
{
|
{
|
||||||
explicit Caller(Ret (Class::*t_func)(Param...)) : m_func(t_func) {}
|
constexpr explicit Caller(Ret (Class::*t_func)(Param...)) : m_func(t_func) {}
|
||||||
|
|
||||||
template<typename ... Inner>
|
template<typename ... Inner>
|
||||||
Ret operator()(Class &o, Inner&& ... inner) const {
|
constexpr Ret operator()(Class &o, Inner&& ... inner) const {
|
||||||
return (o.*m_func)(std::forward<Inner>(inner)...);
|
return (o.*m_func)(std::forward<Inner>(inner)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user