mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-07 01:06:54 +08:00
Enable ChaiScript compilation for C++17
Closes #348 This works by taking into account the fact that `noexcept` is now part of the type system in C++17. However, this would conflict with pre-C++17 compilers, so I have added a feature macro around it
This commit is contained in:
parent
a999ea3692
commit
9f8b57c145
@ -48,6 +48,7 @@ namespace chaiscript
|
|||||||
chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Proxy_Function_Callable_Impl<Signature, T>>(t));
|
chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Proxy_Function_Callable_Impl<Signature, T>>(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename Ret, typename ... Param>
|
template<typename Ret, typename ... Param>
|
||||||
Proxy_Function fun(Ret (*func)(Param...))
|
Proxy_Function fun(Ret (*func)(Param...))
|
||||||
{
|
{
|
||||||
@ -77,13 +78,45 @@ namespace chaiscript
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename Class /*, typename = typename std::enable_if<std::is_member_object_pointer<T>::value>::type*/>
|
template<typename T, typename Class /*, typename = typename std::enable_if<std::is_member_object_pointer<T>::value>::type*/>
|
||||||
Proxy_Function fun(T Class::* m /*, typename std::enable_if<std::is_member_object_pointer<T>::value>::type* = 0*/ )
|
Proxy_Function fun(T Class::* m /*, typename std::enable_if<std::is_member_object_pointer<T>::value>::type* = 0*/ )
|
||||||
{
|
{
|
||||||
return Proxy_Function(chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Attribute_Access<T, Class>>(m));
|
return Proxy_Function(chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Attribute_Access<T, Class>>(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only compile this bit if noexcept is part of the type system
|
||||||
|
//
|
||||||
|
#if __cpp_noexcept_function_type >= 201510
|
||||||
|
template<typename Ret, typename ... Param>
|
||||||
|
Proxy_Function fun(Ret (*func)(Param...) noexcept)
|
||||||
|
{
|
||||||
|
auto fun_call = dispatch::detail::Fun_Caller<Ret, Param...>(func);
|
||||||
|
|
||||||
|
return Proxy_Function(
|
||||||
|
chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Proxy_Function_Callable_Impl<Ret (Param...), decltype(fun_call)>>(fun_call));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Ret, typename Class, typename ... Param>
|
||||||
|
Proxy_Function fun(Ret (Class::*t_func)(Param...) const noexcept)
|
||||||
|
{
|
||||||
|
auto call = dispatch::detail::Const_Caller<Ret, Class, Param...>(t_func);
|
||||||
|
|
||||||
|
return Proxy_Function(
|
||||||
|
chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Proxy_Function_Callable_Impl<Ret (const Class &, Param...), decltype(call)>>(call));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Ret, typename Class, typename ... Param>
|
||||||
|
Proxy_Function fun(Ret (Class::*t_func)(Param...) noexcept)
|
||||||
|
{
|
||||||
|
auto call = dispatch::detail::Caller<Ret, Class, Param...>(t_func);
|
||||||
|
|
||||||
|
return Proxy_Function(
|
||||||
|
chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Proxy_Function_Callable_Impl<Ret (Class &, Param...), decltype(call)>>(call));
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user