Remove automagic wrapping to std::function<>
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user