Remove automagic wrapping to std::function<>

This commit is contained in:
Jason Turner
2015-05-22 09:39:21 -06:00
parent 03143a9f83
commit 630c618ae7
3 changed files with 2 additions and 19 deletions

View File

@@ -47,7 +47,7 @@ namespace chaiscript
#ifndef CHAISCRIPT_NO_THREADS
lib->add(standard_library::future_type<std::future<chaiscript::Boxed_Value>>("future"));
lib->add(chaiscript::fun<std::future<Boxed_Value> (const std::function<chaiscript::Boxed_Value ()> &)>([](const std::function<chaiscript::Boxed_Value ()> &t_func){ return std::async(std::launch::async, t_func);}), "async");
lib->add(chaiscript::fun([](const std::function<chaiscript::Boxed_Value ()> &t_func){ return std::async(std::launch::async, t_func);}), "async");
#endif
return lib;

View File

@@ -144,22 +144,6 @@ namespace chaiscript
}
/// \brief Creates a new Proxy_Function object from a std::function object
/// \param[in] f std::function to expose to ChaiScript
///
/// \b Example:
/// \code
/// std::function<int (char, float, std::string)> f = get_some_function();
/// chaiscript::ChaiScript chai;
/// chai.add(fun(f), "some_function");
/// \endcode
///
/// \sa \ref adding_functions
template<typename T>
Proxy_Function fun(const std::function<T> &f)
{
return Proxy_Function(chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Proxy_Function_Impl<T>>(f));
}
/// \brief Creates a new Proxy_Function object from a free function, member function or data member and binds the first parameter of it

View File

@@ -37,8 +37,7 @@ TEST_CASE("C++11 Lambdas Can Be Registered")
// in an std::function or provide the signature
chaiscript::ChaiScript chai;
// provide the signature
chai.add(chaiscript::fun<std::string ()>([] { return "hello"; } ), "f1");
chai.add(chaiscript::fun([]()->std::string { return "hello"; } ), "f1");
// wrap
chai.add(chaiscript::fun(std::function<std::string ()>([] { return "world"; } )), "f2");