functional

The contents of this module can be included with the header hpx/modules/functional.hpp. These headers may be used by user-code but are not guaranteed stable (neither header location nor contents). You are using these at your own risk. If you wish to use non-public functionality from a module we strongly suggest only including the module header hpx/modules/functional.hpp, not the particular header in which the functionality you would like to use is defined. See Public API for a list of names that are part of the public HPX API.

Header hpx/functional/bind.hpp

namespace hpx
namespace serialization

Functions

template<typename Archive, typename F, typename ...Ts>
void serialize(Archive &ar, ::hpx::util::detail::bound<F, Ts...> &bound, unsigned int const version = 0)
template<typename Archive, std::size_t I>
void serialize(Archive &ar, ::hpx::util::detail::placeholder<I>&, unsigned int const = 0)
namespace util

Functions

template<typename F, typename ...Ts, typename Enable = typename std::enable_if<!traits::is_action<typename std::decay<F>::type>::value>::type>
constexpr detail::bound<typename std::decay<F>::type, typename util::make_index_pack<sizeof...(Ts)>::type, typename util::decay_unwrap<Ts>::type...> bind(F &&f, Ts&&... vs)
namespace placeholders

Variables

constexpr detail::placeholder<1> _1 = {}
constexpr detail::placeholder<2> _2 = {}
constexpr detail::placeholder<3> _3 = {}
constexpr detail::placeholder<4> _4 = {}
constexpr detail::placeholder<5> _5 = {}
constexpr detail::placeholder<6> _6 = {}
constexpr detail::placeholder<7> _7 = {}
constexpr detail::placeholder<8> _8 = {}
constexpr detail::placeholder<9> _9 = {}

Header hpx/functional/bind_back.hpp

namespace hpx
namespace serialization

Functions

template<typename Archive, typename F, typename ...Ts>
void serialize(Archive &ar, ::hpx::util::detail::bound_back<F, Ts...> &bound, unsigned int const version = 0)
namespace util

Functions

template<typename F, typename ...Ts>
constexpr detail::bound_back<typename std::decay<F>::type, typename util::make_index_pack<sizeof...(Ts)>::type, typename util::decay_unwrap<Ts>::type...> bind_back(F &&f, Ts&&... vs)
template<typename F>
constexpr std::decay<F>::type bind_back(F &&f)

Header hpx/functional/bind_front.hpp

namespace hpx
namespace serialization

Functions

template<typename Archive, typename F, typename ...Ts>
void serialize(Archive &ar, ::hpx::util::detail::bound_front<F, Ts...> &bound, unsigned int const version = 0)
namespace util

Functions

template<typename F, typename ...Ts>
constexpr detail::bound_front<typename std::decay<F>::type, typename util::make_index_pack<sizeof...(Ts)>::type, typename util::decay_unwrap<Ts>::type...> bind_front(F &&f, Ts&&... vs)
template<typename F>
constexpr std::decay<F>::type bind_front(F &&f)

Header hpx/functional/deferred_call.hpp

namespace hpx
namespace serialization

Functions

template<typename Archive, typename F, typename ...Ts>
void serialize(Archive &ar, ::hpx::util::detail::deferred<F, Ts...> &d, unsigned int const version = 0)
namespace util

Functions

template<typename F, typename ...Ts>
detail::deferred<typename std::decay<F>::type, typename util::make_index_pack<sizeof...(Ts)>::type, typename util::decay_unwrap<Ts>::type...> deferred_call(F &&f, Ts&&... vs)
template<typename F>
std::decay<F>::type deferred_call(F &&f)

Header hpx/functional/first_argument.hpp

Header hpx/functional/function.hpp

Defines

HPX_UTIL_REGISTER_FUNCTION_DECLARATION(Sig, F, Name)
HPX_UTIL_REGISTER_FUNCTION(Sig, F, Name)
namespace hpx
namespace util

Typedefs

using function_nonser = function<Sig, false>
template<typename R, typename ...Ts, bool Serializable>
class function<R(Ts...), Serializable> : public detail::basic_function<R(Ts...), true, Serializable>
#include <function.hpp>

Public Types

typedef R result_type

Public Functions

constexpr function(std::nullptr_t = nullptr)
function(function const&)
function(function&&)
function &operator=(function const&)
function &operator=(function&&)
template<typename F, typename FD = typename std::decay<F>::type, typename Enable1 = typename std::enable_if<!std::is_same<FD, function>::value>::type, typename Enable2 = typename std::enable_if<traits::is_invocable_r<R, FD&, Ts...>::value>::type>
function(F &&f)
template<typename F, typename FD = typename std::decay<F>::type, typename Enable1 = typename std::enable_if<!std::is_same<FD, function>::value>::type, typename Enable2 = typename std::enable_if<traits::is_invocable_r<R, FD&, Ts...>::value>::type>
function &operator=(F &&f)

Private Types

template<>
using base_type = detail::basic_function<R(Ts...), true, Serializable>

Header hpx/functional/function_ref.hpp

namespace hpx
namespace util
template<typename R, typename ...Ts>
class function_ref<R(Ts...)>
#include <function_ref.hpp>

Public Functions

template<typename F, typename FD = typename std::decay<F>::type, typename Enable = typename std::enable_if<!std::is_same<FD, function_ref>::value && traits::is_invocable_r<R, F&, Ts...>::value>::type>
function_ref(F &&f)
function_ref(function_ref const &other)
template<typename F, typename FD = typename std::decay<F>::type, typename Enable = typename std::enable_if<!std::is_same<FD, function_ref>::value && traits::is_invocable_r<R, F&, Ts...>::value>::type>
function_ref &operator=(F &&f)
function_ref &operator=(function_ref const &other)
template<typename F, typename T = typename std::remove_reference<F>::type, typename Enable = typename std::enable_if<!std::is_pointer<T>::value>::type>
void assign(F &&f)
template<typename T>
void assign(std::reference_wrapper<T> f_ref)
template<typename T>
void assign(T *f_ptr)
void swap(function_ref &f)
R operator()(Ts... vs) const
std::size_t get_function_address() const
char const *get_function_annotation() const
util::itt::string_handle get_function_annotation_itt() const

Protected Attributes

template<>
R (*vptr)(void*, Ts&&...)
void *object

Private Types

template<>
using VTable = detail::function_ref_vtable<R(Ts...)>

Private Static Functions

template<typename T>
static VTable const *get_vtable()

Header hpx/functional/invoke.hpp

Defines

HPX_INVOKE(F, ...)
HPX_INVOKE_R(R, F, ...)
namespace hpx
namespace util

Functions

template<typename F, typename ...Ts>
constexpr util::invoke_result<F, Ts...>::type invoke(F &&f, Ts&&... vs)

Invokes the given callable object f with the content of the argument pack vs

Return

The result of the callable object when it’s called with the given argument types.

Note

This function is similar to std::invoke (C++17)

Parameters
  • 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).

  • vs: An arbitrary pack of arguments

Exceptions
  • std::exception: like objects thrown by call to object f with the argument types vs.

template<typename R, typename F, typename ...Ts>
constexpr R invoke_r(F &&f, Ts&&... vs)

Invokes the given callable object f with the content of the argument pack vs

Return

The result of the callable object when it’s called with the given argument types.

Note

This function is similar to std::invoke (C++17)

Parameters
  • 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).

  • vs: An arbitrary pack of arguments

Exceptions
  • std::exception: like objects thrown by call to object f with the argument types vs.

Template Parameters
  • R: The result type of the function when it’s called with the content of the given argument types vs.

namespace functional
struct invoke
#include <invoke.hpp>

Public Functions

template<typename F, typename ...Ts>
constexpr util::invoke_result<F, Ts...>::type operator()(F &&f, Ts&&... vs) const
template<typename R>
struct invoke_r
#include <invoke.hpp>

Public Functions

template<typename F, typename ...Ts>
constexpr R operator()(F &&f, Ts&&... vs) const

Header hpx/functional/invoke_fused.hpp

namespace hpx
namespace util

Functions

template<typename F, typename Tuple>
constexpr detail::invoke_fused_result<F, Tuple>::type invoke_fused(F &&f, Tuple &&t)

Invokes the given callable object f with the content of the sequenced type t (tuples, pairs)

Return

The result of the callable object when it’s called with the content of the given sequenced type.

Note

This function is similar to std::apply (C++17)

Parameters
  • 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).

  • t: A type which is content accessible through a call to hpx::util::get.

Exceptions
  • std::exception: like objects thrown by call to object f with the arguments contained in the sequenceable type t.

template<typename R, typename F, typename Tuple>
constexpr R invoke_fused_r(F &&f, Tuple &&t)

Invokes the given callable object f with the content of the sequenced type t (tuples, pairs)

Return

The result of the callable object when it’s called with the content of the given sequenced type.

Note

This function is similar to std::apply (C++17)

Parameters
  • 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).

  • t: A type which is content accessible through a call to hpx::util::get.

Exceptions
  • std::exception: like objects thrown by call to object f with the arguments contained in the sequenceable type t.

Template Parameters
  • R: The result type of the function when it’s called with the content of the given sequenced type.

Header hpx/functional/invoke_result.hpp

namespace hpx
namespace util

Functions

template<typename T>struct hpx::util::HPX_DEPRECATED_V(1, 5, "result_of is deprecated, use invoke_result instead.")

Header hpx/functional/mem_fn.hpp

namespace hpx
namespace util

Functions

template<typename M, typename C>
constexpr detail::mem_fn<M C::*> mem_fn(M C::* pm)
template<typename R, typename C, typename ...Ps>
constexpr detail::mem_fn<R (C::*)(Ps...)> mem_fn(R (C::* pm)(Ps...))
template<typename R, typename C, typename ...Ps>
constexpr detail::mem_fn<R (C::*)(Ps...) const> mem_fn(R (C::* pm)(Ps...) const)

Header hpx/functional/one_shot.hpp

namespace hpx
namespace serialization

Functions

template<typename Archive, typename F>
void serialize(Archive &ar, ::hpx::util::detail::one_shot_wrapper<F> &one_shot_wrapper, unsigned int const version = 0)
namespace util

Functions

template<typename F>
constexpr detail::one_shot_wrapper<typename std::decay<F>::type> one_shot(F &&f)

Header hpx/functional/protect.hpp

namespace hpx
namespace util

Functions

template<typename T>
std::enable_if<traits::is_bind_expression<typename std::decay<T>::type>::value, detail::protected_bind<typename std::decay<T>::type>>::type protect(T &&f)
template<typename T>
std::enable_if<!traits::is_bind_expression<typename std::decay<T>::type>::value, T>::type protect(T &&v)

Header hpx/functional/serialization/serializable_function.hpp

Header hpx/functional/serialization/serializable_unique_function.hpp

Header hpx/functional/tag_invoke.hpp

namespace hpx
namespace functional

Typedefs

using tag_invoke_result = invoke_result<decltype(tag_invoke), Tag, Args...>

hpx::functional::tag_invoke_result<Tag, Args...> is the trait returning the result type of the call hpx::functioanl::tag_invoke. This can be used in a SFINAE context.

using tag_invoke_result_t = typename tag_invoke_result<Tag, Args...>::type

hpx::functional::tag_invoke_result_t<Tag, Args...> evaluates to hpx::functional::tag_invoke_result_t<Tag, Args...>::type

Variables

template<typename Tag, typename ...Args>
constexpr bool is_tag_invocable_v = is_tag_invocable<Tag, Args...>::value

hpx::functional::is_tag_invocable_v<Tag, Args...> evaluates to hpx::functional::is_tag_invocable<Tag, Args...>::value

template<typename Tag, typename ...Args>
constexpr bool is_nothrow_tag_invocable_v = is_nothrow_tag_invocable<Tag, Args...>::value

hpx::functional::is_tag_invocable_v<Tag, Args...> evaluates to hpx::functional::is_tag_invocable<Tag, Args...>::value

template<typename Tag, typename ...Args>
struct is_nothrow_tag_invocable
#include <tag_invoke.hpp>

hpx::functional::is_nothrow_tag_invocable<Tag, Args...> is std::true_type if an overload of tag_invoke(tag, args...) can be found via ADL and is noexcept.

template<typename Tag, typename ...Args>
struct is_tag_invocable
#include <tag_invoke.hpp>

hpx::functional::is_tag_invocable<Tag, Args...> is std::true_type if an overload of tag_invoke(tag, args...) can be found via ADL.

template<typename Tag>
struct tag
#include <tag_invoke.hpp>

hpx::functional::tag<Tag> defines a base class that implements the necessary tag dispatching functionality for a given type Tag

namespace unspecified

Variables

constexpr unspecified tag_invoke = unspecified

The hpx::functional::tag_invoke name defines a constexpr object that is invocable with one or more arguments. The first argument is a ‘tag’ (typically a CPO). It is only invocable if an overload of tag_invoke() that accepts the same arguments could be found via ADL.

The evaluation of the expression hpx::tag_invoke(tag, args...) is equivalent to evaluating the unqualified call to tag_invoke(decay-copy(tag), std::forward<Args>(args)...).

hpx::functional::tag_invoke is implemented against P1895.

Example: Defining a new customization point foo:

namespace mylib {
    inline constexpr
        struct foo_fn final : hpx::functional::tag<foo_fn>
        {
        } foo{};
}

Defining an object bar which customizes foo:

struct bar
{
    int x = 42;

    friend constexpr int tag_invoke(mylib::foo_fn, bar const& x)
    {
        return b.x;
    }
};

Using the customization point:

static_assert(42 == mylib::foo(bar{}), "The answer is 42");

Header hpx/functional/traits/get_action_name.hpp

Header hpx/functional/traits/get_function_address.hpp

template<typename R, typename Obj, typename ...Ts>
struct get_function_address<R (Obj::*)(Ts...)>
#include <get_function_address.hpp>

Public Static Functions

static std::size_t call(R (Obj::* f)(Ts...))
template<typename R, typename Obj, typename ...Ts>
struct get_function_address<R (Obj::*)(Ts...) const>
#include <get_function_address.hpp>

Public Static Functions

static std::size_t call(R (Obj::* f)(Ts...) const)
namespace hpx
namespace traits
template<typename F, typename Enable = void>
struct get_function_address
#include <get_function_address.hpp>

Public Static Functions

static std::size_t call(F const &f)
template<typename R, typename ...Ts>
struct get_function_address<R (*)(Ts...)>
#include <get_function_address.hpp>

Public Static Functions

static std::size_t call(R (*f)(Ts...))
template<typename R, typename Obj, typename ...Ts>
struct get_function_address<R (Obj::*)(Ts...) const>
#include <get_function_address.hpp>

Public Static Functions

static std::size_t call(R (Obj::* f)(Ts...) const)
template<typename R, typename Obj, typename ...Ts>
struct get_function_address<R (Obj::*)(Ts...)>
#include <get_function_address.hpp>

Public Static Functions

static std::size_t call(R (Obj::* f)(Ts...))

Header hpx/functional/traits/get_function_annotation.hpp

namespace hpx
namespace traits
template<typename F, typename Enable = void>
struct get_function_annotation
#include <get_function_annotation.hpp>

Public Static Functions

static char const *call(F const&)

Header hpx/functional/traits/is_action.hpp

Header hpx/functional/traits/is_bind_expression.hpp

namespace hpx
namespace traits
template<typename T>
struct is_bind_expression : public std::is_bind_expression<T>
#include <is_bind_expression.hpp>

Subclassed by hpx::traits::is_bind_expression< T const >

Header hpx/functional/traits/is_invocable.hpp

namespace hpx
namespace traits

Functions

template<typename T, typename R = void>struct hpx::traits::HPX_DEPRECATED_V(1, 5, "is_callable is deprecated, use is_invocable instead.")

Header hpx/functional/traits/is_placeholder.hpp

namespace hpx
namespace traits
template<typename T>
struct is_placeholder
#include <is_placeholder.hpp>

If T is a standard, Boost, or HPX placeholder (_1, _2, _3, …) then this template is derived from std::integral_constant<int, 1>, std::integral_constant<int, 2>, std::integral_constant<int, 3>, respectively. Otherwise it is derived from , std::integral_constant<int, 0>.

Header hpx/functional/unique_function.hpp

Defines

HPX_UTIL_REGISTER_UNIQUE_FUNCTION_DECLARATION(Sig, F, Name)
HPX_UTIL_REGISTER_UNIQUE_FUNCTION(Sig, F, Name)
namespace hpx
namespace util

Typedefs

using unique_function_nonser = unique_function<Sig, false>
template<typename R, typename ...Ts, bool Serializable>
class unique_function<R(Ts...), Serializable> : public detail::basic_function<R(Ts...), false, Serializable>
#include <unique_function.hpp>

Public Types

typedef R result_type

Public Functions

constexpr unique_function(std::nullptr_t = nullptr)
unique_function(unique_function&&)
unique_function &operator=(unique_function&&)
template<typename F, typename FD = typename std::decay<F>::type, typename Enable1 = typename std::enable_if<!std::is_same<FD, unique_function>::value>::type, typename Enable2 = typename std::enable_if<traits::is_invocable_r<R, FD&, Ts...>::value>::type>
unique_function(F &&f)
template<typename F, typename FD = typename std::decay<F>::type, typename Enable1 = typename std::enable_if<!std::is_same<FD, unique_function>::value>::type, typename Enable2 = typename std::enable_if<traits::is_invocable_r<R, FD&, Ts...>::value>::type>
unique_function &operator=(F &&f)

Private Types

template<>
using base_type = detail::basic_function<R(Ts...), false, Serializable>