From 9f8b57c145da9251e343750f416880092a90e6b5 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Tue, 30 May 2017 09:16:20 -0600 Subject: [PATCH] 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 --- .../dispatchkit/register_function.hpp | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/include/chaiscript/dispatchkit/register_function.hpp b/include/chaiscript/dispatchkit/register_function.hpp index ef17fb86..e660790d 100644 --- a/include/chaiscript/dispatchkit/register_function.hpp +++ b/include/chaiscript/dispatchkit/register_function.hpp @@ -48,6 +48,7 @@ namespace chaiscript chaiscript::make_shared>(t)); } + template Proxy_Function fun(Ret (*func)(Param...)) { @@ -77,13 +78,45 @@ namespace chaiscript } - template::value>::type*/> Proxy_Function fun(T Class::* m /*, typename std::enable_if::value>::type* = 0*/ ) { return Proxy_Function(chaiscript::make_shared>(m)); } +// only compile this bit if noexcept is part of the type system +// +#if __cpp_noexcept_function_type >= 201510 + template + Proxy_Function fun(Ret (*func)(Param...) noexcept) + { + auto fun_call = dispatch::detail::Fun_Caller(func); + + return Proxy_Function( + chaiscript::make_shared>(fun_call)); + + } + + template + Proxy_Function fun(Ret (Class::*t_func)(Param...) const noexcept) + { + auto call = dispatch::detail::Const_Caller(t_func); + + return Proxy_Function( + chaiscript::make_shared>(call)); + } + + template + Proxy_Function fun(Ret (Class::*t_func)(Param...) noexcept) + { + auto call = dispatch::detail::Caller(t_func); + + return Proxy_Function( + chaiscript::make_shared>(call)); + + } +#endif +