diff --git a/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index 575803e..ca43084 100644 --- a/include/chaiscript/dispatchkit/bootstrap.hpp +++ b/include/chaiscript/dispatchkit/bootstrap.hpp @@ -12,8 +12,8 @@ #include "register_function.hpp" #include "operators.hpp" #include "boxed_number.hpp" -#include #include +#include namespace chaiscript { @@ -346,7 +346,9 @@ namespace chaiscript static std::vector do_return_boxed_value_vector(FunctionType f, const dispatch::Proxy_Function_Base *b) { - typedef typename boost::function_types::result_type::type Vector; + typedef decltype(std::mem_fn(f)) MemFunType; + typedef typename MemFunType::result_type Vector; + Vector v = (b->*f)(); std::vector vbv; diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index 04936be..1d51639 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include "boxed_value.hpp" #include "type_info.hpp" diff --git a/include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp b/include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp index c024563..f6fb7bf 100644 --- a/include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp +++ b/include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp @@ -246,9 +246,9 @@ namespace chaiscript { //Can only be used with related polymorphic types //may be expanded some day to support conversions other than child -> parent - BOOST_STATIC_ASSERT((std::is_base_of::value)); - BOOST_STATIC_ASSERT(std::is_polymorphic::value); - BOOST_STATIC_ASSERT(std::is_polymorphic::value); + static_assert(std::is_base_of::value, "Classes are not related by inheritance"); + static_assert(std::is_polymorphic::value, "Base class must be polymorphic"); + static_assert(std::is_polymorphic::value, "Derived class must be polymorphic"); return detail::Dynamic_Conversions::create(); } diff --git a/include/chaiscript/dispatchkit/register_function.hpp b/include/chaiscript/dispatchkit/register_function.hpp index e62064a..2bb4cfe 100644 --- a/include/chaiscript/dispatchkit/register_function.hpp +++ b/include/chaiscript/dispatchkit/register_function.hpp @@ -9,8 +9,6 @@ #include "dispatchkit.hpp" #include "bind_first.hpp" -#include -#include namespace chaiscript { @@ -18,39 +16,48 @@ namespace chaiscript { namespace detail { - template + template + struct FunctionSignature + { + }; + + template + struct FunctionSignature > + { + typedef Sig Signature; + }; + + template + std::function to_function(Ret (*func)(Args...)) + { + return std::function(func); + } + + template + std::function to_function(Ret (Class::*func)(Args...)) + { + return std::function(func); + } + + template + std::function to_function(Ret (Class::*func)(Args...) const) + { + return std::function(func); + } + + template struct Fun_Helper { template static Proxy_Function go(T t) { return Proxy_Function( - new Proxy_Function_Impl< - typename boost::function_types::function_type >::type> ( - std::function< - typename boost::function_types::function_type >::type - >(t))); + new Proxy_Function_Impl::Signature>(to_function(t))); } }; template<> - struct Fun_Helper - { - template - static Proxy_Function go(T t) - { - return Proxy_Function( - new Proxy_Function_Impl< - typename boost::function_types::function_type >::type> ( - std::function< - typename boost::function_types::function_type >::type - >(std::mem_fn(t)))); - } - }; - - - template<> - struct Fun_Helper + struct Fun_Helper { template static Proxy_Function go(T Class::* m) @@ -101,7 +108,7 @@ namespace chaiscript template Proxy_Function fun(T t) { - return dispatch::detail::Fun_Helper::value, std::is_member_function_pointer::value>::go(t); + return dispatch::detail::Fun_Helper::value>::go(t); } /// \brief Creates a new Proxy_Function object from a free function, member function or data member and binds the first parameter of it diff --git a/include/chaiscript/language/chaiscript_parser.hpp b/include/chaiscript/language/chaiscript_parser.hpp index aa10437..67a5ddc 100644 --- a/include/chaiscript/language/chaiscript_parser.hpp +++ b/include/chaiscript/language/chaiscript_parser.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "chaiscript_prelude.hpp" #include "chaiscript_common.hpp"