tag_invoke

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx
namespace util

Typedefs

template<typename F, typename ...Ts>
using invoke_result_t = typename invoke_result<F, Ts...>::type
namespace hpx
namespace functional

Typedefs

template<typename Tag, typename ...Args>
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::functional::tag_invoke. This can be used in a SFINAE context.

template<typename Tag, typename ...Args>
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

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), HPX_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");

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

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

hpx::functional::tag_noexcept<Tag> defines a base class that implements the necessary tag dispatching functionality for a given type Tag The implementation has to be noexcept

namespace hpx

Variables

template<typename F, typename ...Ts>
constexpr bool is_invocable_v = is_invocable<F, Ts...>::value
template<typename R, typename F, typename ...Ts>
constexpr bool is_invocable_r_v = is_invocable_r<R, F, Ts...>::value