5#ifndef TETL_FUNCTIONAL_FUNCTION_REF_HPP
6#define TETL_FUNCTIONAL_FUNCTION_REF_HPP
21template <
bool Noexcept,
typename Signature>
24template <
bool Noexcept,
typename R,
typename... Args>
25struct function_ref<Noexcept, R(Args...)> {
29 : _obj(
const_cast<void*
>(
reinterpret_cast<void const*
>(
etl::addressof(f))))
30 , _callable{+[](
void* obj, Args... args) -> R {
31 auto* func =
reinterpret_cast<etl::add_pointer_t<F>
>(obj);
43 auto operator()(Args... args)
const noexcept(Noexcept) -> R {
return _callable(_obj,
etl::forward<Args>(args)...); }
46 using internal_signature_t = R (*)(
void*, Args...)
noexcept(Noexcept);
49 internal_signature_t _callable{
nullptr};
57template <
typename Signature>
60template <
typename R,
typename... Args>
61struct function_ref<R(Args...)> : etl::detail::function_ref<false, R(Args...)> {
65template <
typename R,
typename... Args>
66struct function_ref<R(Args...) noexcept> : etl::detail::function_ref<true, R(Args...)> {
70template <
typename R,
typename... Args>
Definition adjacent_find.hpp:8
constexpr auto addressof(T &arg) noexcept -> T *
Obtains the actual address of the object or function arg, even in presence of overloaded operator&.
Definition addressof.hpp:15
constexpr auto invoke_r(F &&f, Args &&... args) -> R
Definition invoke_r.hpp:16
constexpr auto is_invocable_r_v
Definition is_invocable_r.hpp:15
constexpr bool is_same_v
Definition is_same.hpp:11
function_ref(R(*)(Args...)) -> function_ref< R(Args...)>
constexpr auto forward(remove_reference_t< T > ¶m) noexcept -> T &&
Forwards lvalues as either lvalues or as rvalues, depending on T. When t is a forwarding reference (a...
Definition forward.hpp:18
Non-owning view of a callable.
Definition function_ref.hpp:58