Commit 72229769 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

rename Function private helper ResultOf

Summary: `ResultOf` is no longer the most-suitable name. This helper has long been a SFINAE helper and its actual output did not matter, but now that it is always `void` the name is even less clear. Rename it.

Reviewed By: luciang

Differential Revision: D33155200

fbshipit-source-id: a12842c6be38bd82bfffa85193ec265bc4d803ad
parent c465314c
...@@ -290,7 +290,7 @@ template < ...@@ -290,7 +290,7 @@ template <
typename To, typename To,
typename = typename std::enable_if< typename = typename std::enable_if<
!std::is_reference<To>::value || std::is_reference<From>::value>::type> !std::is_reference<To>::value || std::is_reference<From>::value>::type>
using SafeResultOf = decltype(void(static_cast<To>(std::declval<From>()))); using IfSafeResultImpl = decltype(void(static_cast<To>(std::declval<From>())));
#if defined(_MSC_VER) #if defined(_MSC_VER)
// Need a workaround for MSVC to avoid the inscrutable error: // Need a workaround for MSVC to avoid the inscrutable error:
...@@ -359,9 +359,8 @@ struct FunctionTraits<ReturnType(Args...)> { ...@@ -359,9 +359,8 @@ struct FunctionTraits<ReturnType(Args...)> {
using NonConstSignature = ReturnType(Args...); using NonConstSignature = ReturnType(Args...);
using OtherSignature = ConstSignature; using OtherSignature = ConstSignature;
template <typename F> template <typename F, typename R = CallableResult<std::decay_t<F>&, Args...>>
using ResultOf = using IfSafeResult = IfSafeResultImpl<R, ReturnType>;
SafeResultOf<CallableResult<std::decay_t<F>&, Args...>, ReturnType>;
template <typename Fun> template <typename Fun>
static ReturnType callSmall(CallArg<Args>... args, Data& p) { static ReturnType callSmall(CallArg<Args>... args, Data& p) {
...@@ -412,9 +411,10 @@ struct FunctionTraits<ReturnType(Args...) const> { ...@@ -412,9 +411,10 @@ struct FunctionTraits<ReturnType(Args...) const> {
using NonConstSignature = ReturnType(Args...); using NonConstSignature = ReturnType(Args...);
using OtherSignature = NonConstSignature; using OtherSignature = NonConstSignature;
template <typename F> template <
using ResultOf = typename F,
SafeResultOf<CallableResult<const std::decay_t<F>&, Args...>, ReturnType>; typename R = CallableResult<const std::decay_t<F>&, Args...>>
using IfSafeResult = IfSafeResultImpl<R, ReturnType>;
template <typename Fun> template <typename Fun>
static ReturnType callSmall(CallArg<Args>... args, Data& p) { static ReturnType callSmall(CallArg<Args>... args, Data& p) {
...@@ -466,9 +466,8 @@ struct FunctionTraits<ReturnType(Args...) noexcept> { ...@@ -466,9 +466,8 @@ struct FunctionTraits<ReturnType(Args...) noexcept> {
using NonConstSignature = ReturnType(Args...) noexcept; using NonConstSignature = ReturnType(Args...) noexcept;
using OtherSignature = ConstSignature; using OtherSignature = ConstSignature;
template <typename F> template <typename F, typename R = CallableResult<std::decay_t<F>&, Args...>>
using ResultOf = using IfSafeResult = IfSafeResultImpl<R, ReturnType>;
SafeResultOf<CallableResult<std::decay_t<F>&, Args...>, ReturnType>;
template <typename Fun> template <typename Fun>
static ReturnType callSmall(CallArg<Args>... args, Data& p) noexcept { static ReturnType callSmall(CallArg<Args>... args, Data& p) noexcept {
...@@ -519,9 +518,10 @@ struct FunctionTraits<ReturnType(Args...) const noexcept> { ...@@ -519,9 +518,10 @@ struct FunctionTraits<ReturnType(Args...) const noexcept> {
using NonConstSignature = ReturnType(Args...) noexcept; using NonConstSignature = ReturnType(Args...) noexcept;
using OtherSignature = NonConstSignature; using OtherSignature = NonConstSignature;
template <typename F> template <
using ResultOf = typename F,
SafeResultOf<CallableResult<const std::decay_t<F>&, Args...>, ReturnType>; typename R = CallableResult<const std::decay_t<F>&, Args...>>
using IfSafeResult = IfSafeResultImpl<R, ReturnType>;
template <typename Fun> template <typename Fun>
static ReturnType callSmall(CallArg<Args>... args, Data& p) noexcept { static ReturnType callSmall(CallArg<Args>... args, Data& p) noexcept {
...@@ -709,7 +709,7 @@ class Function final : private detail::function::FunctionTraits<FunctionType> { ...@@ -709,7 +709,7 @@ class Function final : private detail::function::FunctionTraits<FunctionType> {
* signature matches (i.e. it returns an object convertible to `R` when called * signature matches (i.e. it returns an object convertible to `R` when called
* with `Args...`). * with `Args...`).
* *
* \note `typename Traits::template ResultOf<Fun>` prevents this overload * \note `typename Traits::template IfSafeResult<Fun>` prevents this overload
* from being selected by overload resolution when `fun` is not a compatible * from being selected by overload resolution when `fun` is not a compatible
* function. * function.
* *
...@@ -725,7 +725,7 @@ class Function final : private detail::function::FunctionTraits<FunctionType> { ...@@ -725,7 +725,7 @@ class Function final : private detail::function::FunctionTraits<FunctionType> {
typename Fun, typename Fun,
typename = typename =
std::enable_if_t<!detail::is_similar_instantiation_v<Function, Fun>>, std::enable_if_t<!detail::is_similar_instantiation_v<Function, Fun>>,
typename = typename Traits::template ResultOf<Fun>> typename = typename Traits::template IfSafeResult<Fun>>
/* implicit */ Function(Fun fun) noexcept( /* implicit */ Function(Fun fun) noexcept(
IsSmall<Fun>::value&& noexcept(Fun(std::declval<Fun>()))) IsSmall<Fun>::value&& noexcept(Fun(std::declval<Fun>())))
: Function(std::move(fun), IsSmall<Fun>{}) {} : Function(std::move(fun), IsSmall<Fun>{}) {}
...@@ -741,7 +741,7 @@ class Function final : private detail::function::FunctionTraits<FunctionType> { ...@@ -741,7 +741,7 @@ class Function final : private detail::function::FunctionTraits<FunctionType> {
*/ */
template < template <
typename Signature, typename Signature,
typename = typename Traits::template ResultOf<Function<Signature>>> typename = typename Traits::template IfSafeResult<Function<Signature>>>
Function(Function<Signature>&& that) noexcept( Function(Function<Signature>&& that) noexcept(
noexcept(Function(std::move(that), CoerceTag{}))) noexcept(Function(std::move(that), CoerceTag{})))
: Function(std::move(that), CoerceTag{}) {} : Function(std::move(that), CoerceTag{}) {}
...@@ -827,7 +827,7 @@ class Function final : private detail::function::FunctionTraits<FunctionType> { ...@@ -827,7 +827,7 @@ class Function final : private detail::function::FunctionTraits<FunctionType> {
*/ */
template < template <
typename Signature, typename Signature,
typename = typename Traits::template ResultOf<Function<Signature>>> typename = typename Traits::template IfSafeResult<Function<Signature>>>
Function& operator=(Function<Signature>&& that) noexcept( Function& operator=(Function<Signature>&& that) noexcept(
noexcept(Function(std::move(that)))) { noexcept(Function(std::move(that)))) {
return (*this = Function(std::move(that))); return (*this = Function(std::move(that)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment