Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation to invoke_fused and friends NFC. #2611

Merged
merged 1 commit into from May 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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