#include <folly/CppAttributes.h>
#include <folly/Portability.h>
#include <folly/Traits.h>
+#include <folly/functional/Invoke.h>
namespace folly {
return true;
}
-// Invoke helper
-template <typename F, typename... Args>
-inline constexpr auto invoke(F&& f, Args&&... args)
- -> decltype(std::forward<F>(f)(std::forward<Args>(args)...)) {
- return std::forward<F>(f)(std::forward<Args>(args)...);
-}
-
-template <typename M, typename C, typename... Args>
-inline constexpr auto invoke(M(C::*d), Args&&... args)
- -> decltype(std::mem_fn(d)(std::forward<Args>(args)...)) {
- return std::mem_fn(d)(std::forward<Args>(args)...);
-}
-
} // namespace function
} // namespace detail
// not copyable
Function(const Function&) = delete;
+#if __OBJC__
+ // Delete conversion from Objective-C blocks
+ template <class ReturnType, class... Args>
+ Function(ReturnType (^)(Args...)) = delete;
+#endif
+
/**
* Move constructor
*/
Function& operator=(const Function&) = delete;
+#if __OBJC__
+ // Delete conversion from Objective-C blocks
+ template <class ReturnType, class... Args>
+ Function& operator=(ReturnType (^)(Args...)) = delete;
+#endif
+
/**
* Move assignment operator
*
template <typename Fun>
static ReturnType call(void* object, Args&&... args) {
using Pointer = _t<std::add_pointer<Fun>>;
- return static_cast<ReturnType>(detail::function::invoke(
+ return static_cast<ReturnType>(invoke(
static_cast<Fun&&>(*static_cast<Pointer>(object)),
static_cast<Args&&>(args)...));
}