1#ifndef HALCHECK_LIB_FUNCTIONAL_FUNCTION_VIEW_HPP
2#define HALCHECK_LIB_FUNCTIONAL_FUNCTION_VIEW_HPP
6#include <halcheck/lib/functional/invoke.hpp>
7#include <halcheck/lib/functional/overload.hpp>
8#include <halcheck/lib/type_traits.hpp>
9#include <halcheck/lib/variant.hpp>
11namespace halcheck {
namespace lib {
22template<
typename R,
typename... Args>
23class function_view<R(Args...)> {
38 : _impl(closure{
std::addressof(func), [](
void *impl, Args... args) {
58 [&](
const closure &func) {
return func.invoke(func.self,
std::forward<Args>(args)...); },
66 R (*invoke)(
void *, Args...);
69 lib::variant<R (*)(Args...), closure> _impl;
78template<
typename R,
typename... Args>
79class function_view<R(Args...) const> {
113 [&](
const closure &func) {
return func.invoke(func.self,
std::forward<Args>(args)...); },
121 R (*invoke)(
const void *, Args...);
124 lib::variant<R (*)(Args...), closure> _impl;
R operator()(Args... args) const
Calls the underlying function.*.
Definition function_view.hpp:110
function_view(R(*func)(Args...)) noexcept
Constructs a new function view from a function pointer.
Definition function_view.hpp:103
function_view(F &&func) noexcept
Constructs a new function view from a function object.
Definition function_view.hpp:92
function_view(F &&func) noexcept
Constructs a new function view from a function object.
Definition function_view.hpp:37
R operator()(Args... args) const
Calls the underlying function.
Definition function_view.hpp:55
function_view(R(*func)(Args...)) noexcept
Constructs a new function view from a function pointer.
Definition function_view.hpp:47
HALCHECK_INLINE_CONSTEXPR struct halcheck::lib::@20 invoke
An implementation of std::invoke.
lib::overload< Args... > make_overload(Args... args)
Constructs an overloaded functor from a set of pre-existing functors.
Definition overload.hpp:48
typename std::decay< T >::type decay_t
An implementation of std::decay_t.
Definition type_traits.hpp:101
#define HALCHECK_REQUIRE(...)
Expands to a template argument that is only valid if the given argument evaluates to true.
Definition type_traits.hpp:24
An implementation of std::is_invocable_r.
Definition invoke.hpp:54