35#ifndef LIBSEMIGROUPS_DETAIL_FUNCTION_REF_HPP_
36#define LIBSEMIGROUPS_DETAIL_FUNCTION_REF_HPP_
40#include "libsemigroups/debug.hpp"
44 template <
typename TSignature>
47 template <
typename TReturn,
typename... TArgs>
48 class FunctionRef<TReturn(TArgs...)> {
51 TReturn (*_erased_fn)(
void*, TArgs...);
54 FunctionRef() noexcept : _ptr(
nullptr) {}
57 typename = std::enable_if_t<
58 std::is_invocable_v<T(TArgs...)>
59 && !std::is_same_v<std::decay_t<T>, FunctionRef>>>
60 FunctionRef(T&& x) noexcept
62 _erased_fn = [](
void* ptr, TArgs... xs) -> TReturn {
63 return (*
reinterpret_cast<std::add_pointer_t<T>
>(ptr))(
68 decltype(
auto)
operator()(TArgs... xs)
const
70 LIBSEMIGROUPS_ASSERT(valid());
74 inline bool valid() const noexcept {
75 return _ptr !=
nullptr;
78 inline void invalidate() noexcept {
Namespace for everything in the libsemigroups library.
Definition action.hpp:44