Skip to content

Commit

Permalink
Merge pull request #2611 from Naios/fused
Browse files Browse the repository at this point in the history
Add documentation to invoke_fused and friends NFC.
  • Loading branch information
hkaiser committed May 30, 2017
2 parents 0b4d2f7 + e890af4 commit 6d8baf3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/CMakeLists.txt
Expand Up @@ -171,6 +171,8 @@ set(doxygen_dependencies
"${PROJECT_SOURCE_DIR}/hpx/lcos/when_some.hpp"
"${PROJECT_SOURCE_DIR}/hpx/lcos/wait_each.hpp"
"${PROJECT_SOURCE_DIR}/hpx/lcos/when_each.hpp"
"${PROJECT_SOURCE_DIR}/hpx/util/invoke.hpp"
"${PROJECT_SOURCE_DIR}/hpx/util/invoke_fused.hpp"
"${PROJECT_SOURCE_DIR}/hpx/performance_counters/manage_counter_type.hpp")


Expand Down
8 changes: 8 additions & 0 deletions docs/hpx.idx
Expand Up @@ -511,6 +511,14 @@ when_each_n "" "header\.hpx\.lcos\.when_each.*"
wait_each "" "header\.hpx\.lcos\.wait_each.*"
wait_each_n "" "header\.hpx\.lcos\.wait_each.*"

# hpx/util/invoke.hpp
invoke "" "header\.hpx\.util\.invoke.*"
invoke_r "" "header\.hpx\.util\.invoke_r.*"

# hpx/util/invoke_fused.hpp
invoke_fused "" "header\.hpx\.util\.invoke_fused.*"
invoke_fused_r "" "header\.hpx\.util\.invoke_fused_r.*"

# hpx/hpx_finalize.hpp
finalize "" "hpx\.finalize.*"
terminate "" "hpx\.terminate.*"
Expand Down
22 changes: 22 additions & 0 deletions hpx/util/invoke.hpp
Expand Up @@ -127,6 +127,22 @@ namespace hpx { namespace util
};
}

/// Invokes the given callable object f with the content of
/// the argument pack vs
///
/// \param f Requires to be a callable object.
/// If f is a member function pointer, the first argument in
/// the pack will be treated as the callee (this object).
///
/// \param vs An arbitrary pack of arguments
///
/// \returns The result of the callable object when it's called with
/// the given argument types.
///
/// \throws std::exception like objects thrown by call to object f
/// with the argument types vs.
///
/// \note This function is similar to `std::invoke` (C++17)
template <typename F, typename ...Ts>
HPX_HOST_DEVICE HPX_FORCEINLINE
typename util::result_of<F&&(Ts&&...)>::type
Expand All @@ -138,6 +154,10 @@ namespace hpx { namespace util
std::forward<F>(f), std::forward<Ts>(vs)...);
}

/// \copydoc invoke
///
/// \tparam R The result type of the function when it's called
/// with the content of the given argument types vs.
template <typename R, typename F, typename ...Ts>
HPX_HOST_DEVICE HPX_FORCEINLINE
R invoke_r(F&& f, Ts&&... vs)
Expand All @@ -147,6 +167,7 @@ namespace hpx { namespace util
}

///////////////////////////////////////////////////////////////////////////
/// \cond NOINTERNAL
namespace functional
{
struct invoke
Expand Down Expand Up @@ -175,6 +196,7 @@ namespace hpx { namespace util
}
};
}
/// \endcond
}}

#endif
23 changes: 23 additions & 0 deletions hpx/util/invoke_fused.hpp
Expand Up @@ -68,6 +68,23 @@ namespace hpx { namespace util
}
}

/// Invokes the given callable object f with the content of
/// the sequenced type t (tuples, pairs)
///
/// \param f Must be a callable object. If f is a member function pointer,
/// the first argument in the sequenced type will be treated as
/// the callee (this object).
///
/// \param t A type which is content accessible through a call
/// to hpx#util#get.
///
/// \returns The result of the callable object when it's called with
/// the content of the given sequenced type.
///
/// \throws std::exception like objects thrown by call to object f
/// with the arguments contained in the sequenceable type t.
///
/// \note This function is similar to `std::apply` (C++17)
template <typename F, typename Tuple>
HPX_HOST_DEVICE HPX_FORCEINLINE
typename detail::fused_result_of<F&&(Tuple&&)>::type
Expand All @@ -80,6 +97,10 @@ namespace hpx { namespace util
typename detail::fused_index_pack<Tuple>::type());
}

/// \copydoc invoke_fused
///
/// \tparam R The result type of the function when it's called
/// with the content of the given sequenced type.
template <typename R, typename F, typename Tuple>
HPX_HOST_DEVICE HPX_FORCEINLINE
R invoke_fused_r(F&& f, Tuple&& t)
Expand All @@ -89,6 +110,7 @@ namespace hpx { namespace util
typename detail::fused_index_pack<Tuple>::type());
}
///////////////////////////////////////////////////////////////////////////
/// \cond NOINTERNAL
namespace functional
{
struct invoke_fused
Expand Down Expand Up @@ -119,6 +141,7 @@ namespace hpx { namespace util
}
};
}
/// \endcond
}}

#endif

0 comments on commit 6d8baf3

Please sign in to comment.