typedef typename ArgType<Args...>::FirstArg FirstArg;
};
-// gcc-4.8 refuses to capture a function reference in a lambda. This can be
-// mitigated by casting them to function pointer types first. The following
-// helper is used in Future.h to achieve that where necessary.
-// When compiling with gcc versions 4.9 and up, as well as clang, we do not
-// need to apply FunctionReferenceToPointer (i.e. T can be used instead of
-// FunctionReferenceToPointer<T>).
-// Applying FunctionReferenceToPointer first, the code works on all tested
-// compiler versions: gcc 4.8 and above, cland 3.5 and above.
-
-template <typename T>
-struct FunctionReferenceToPointer {
- using type = T;
-};
-
-template <typename R, typename... Args>
-struct FunctionReferenceToPointer<R (&)(Args...)> {
- using type = R (*)(Args...);
-};
-
} // namespace detail
} // namespace futures
value(), which may rethrow if this has captured an exception. If func
throws, the exception will be captured in the Future that is returned.
*/
- // gcc 4.8 requires that we cast function reference types to function pointer
- // types. Fore more details see the comment on FunctionReferenceToPointer
- // in Future-pre.h.
- // gcc versions 4.9 and above (as well as clang) do not require this hack.
- // For those, the FF tenplate parameter can be removed and occurences of FF
- // replaced with F.
- template <
- typename F,
- typename FF =
- typename futures::detail::FunctionReferenceToPointer<F>::type,
- typename R = futures::detail::callableResult<T, FF>>
+ template <typename F, typename R = futures::detail::callableResult<T, F>>
typename R::Return then(F&& func) {
- typedef typename R::Arg Arguments;
- return thenImplementation<FF, R>(std::forward<FF>(func), Arguments());
+ return thenImplementation<F, R>(std::forward<F>(func), typename R::Arg());
}
/// Variant where func is an member function