diff --git a/include/chaiscript/dispatchkit/bind_first.hpp b/include/chaiscript/dispatchkit/bind_first.hpp index 35e097b..765316d 100644 --- a/include/chaiscript/dispatchkit/bind_first.hpp +++ b/include/chaiscript/dispatchkit/bind_first.hpp @@ -26,6 +26,7 @@ # endif #else # define n BOOST_PP_ITERATION() +# define m BOOST_PP_INC(n) namespace chaiscript { @@ -44,9 +45,9 @@ namespace chaiscript return boost::bind(f, o BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM(n, param, ~)); } - template - boost::function - bind_first(Ret (*f)(BOOST_PP_ENUM_PARAMS(n, Param)), const O &o) + template + boost::function + bind_first(Ret (*f)(BOOST_PP_ENUM_PARAMS(m, Param)), const O &o) { return boost::bind(f, o BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM(n, param, ~)); } diff --git a/src/example.cpp b/src/example.cpp index 5145724..5ba563e 100644 --- a/src/example.cpp +++ b/src/example.cpp @@ -22,6 +22,10 @@ void log(const std::string &module, const std::string &msg) std::cout << "[" << boost::posix_time::microsec_clock::local_time() << "] <" << module << "> " << msg << std::endl; } +void bound_log(const std::string &msg) +{ + log(msg); +} void hello_world(const chaiscript::Boxed_Value &o) { @@ -148,6 +152,7 @@ int main(int argc, char *argv[]) { // Test ability to register a function that excepts a shared_ptr version of a type chai("take_shared_ptr(\"Hello World as a shared_ptr\");"); + chai.add(bound_fun(&bound_log, std::string("Msg")), "BoundFun"); //Dynamic objects test chai.add(chaiscript::Proxy_Function(new Dynamic_Object_Function("TestType", fun(&hello_world))), "hello_world");