4#ifndef TETL_FUNCTIONAL_NOT_FN_HPP
5#define TETL_FUNCTIONAL_NOT_FN_HPP
7#include <etl/_functional/invoke.hpp>
8#include <etl/_type_traits/is_member_pointer.hpp>
9#include <etl/_type_traits/is_pointer.hpp>
10#include <etl/_utility/forward.hpp>
11#include <etl/_utility/move.hpp>
17template <
typename F,
typename... Args>
18concept negate_invocable
19 =
requires(F&& f, Args&&... args) {
not etl::invoke(
etl::forward<F>(f),
etl::forward<Args>(args)...); };
25 template <
typename... Args>
26 requires negate_invocable<F&, Args...>
27 constexpr auto operator()(Args&&... args) &
noexcept(
noexcept(
not etl::invoke(f, etl::forward<Args>(args)...)))
30 return not etl::invoke(f,
etl::forward<Args>(args)...);
33 template <
typename... Args>
34 requires negate_invocable<F
const&, Args...>
35 constexpr auto operator()(Args&&... args)
const&
noexcept(
noexcept(
not etl::invoke(f, etl::forward<Args>(args)...)))
38 return not etl::invoke(f,
etl::forward<Args>(args)...);
41 template <
typename... Args>
42 requires negate_invocable<F, Args...>
44 operator()(Args&&... args) &&
noexcept(
noexcept(
not etl::invoke(etl::move(f), etl::forward<Args>(args)...)))
47 return not etl::invoke(
etl::move(f),
etl::forward<Args>(args)...);
50 template <
typename... Args>
51 requires negate_invocable<F
const, Args...>
53 operator()(Args&&... args)
const&&
noexcept(
noexcept(
not etl::invoke(etl::move(f), etl::forward<Args>(args)...)))
56 return not etl::invoke(
etl::move(f),
etl::forward<Args>(args)...);
59 template <
typename... Args>
60 auto operator()(Args&&...) & ->
void =
delete;
62 template <
typename... Args>
63 auto operator()(Args&&...)
const& ->
void =
delete;
65 template <
typename... Args>
66 auto operator()(Args&&...) && ->
void =
delete;
68 template <
typename... Args>
69 auto operator()(Args&&...)
const&& ->
void =
delete;
72template <
auto ConstFn>
73struct stateless_not_fn {
74 template <
typename... Args>
76 operator()(Args&&... args)
const noexcept(
noexcept(!etl::invoke(ConstFn, etl::forward<Args>(args)...)))
77 ->
decltype(!
etl::invoke(ConstFn,
etl::forward<Args>(args)...))
79 return !
etl::invoke(ConstFn,
etl::forward<Args>(args)...);
86[[nodiscard]]
constexpr auto not_fn(F&& f) -> detail::not_fn_t<
etl::decay_t<F>>
88 return {
etl::forward<F>(f)};
91template <
auto ConstFn>
92[[nodiscard]]
constexpr auto not_fn()
noexcept -> detail::stateless_not_fn<ConstFn>
94 if constexpr (
etl::is_pointer_v<
decltype(ConstFn)>
or etl::is_member_pointer_v<
decltype(ConstFn)>) {
95 static_assert(ConstFn !=
nullptr);
Definition adjacent_find.hpp:9
constexpr auto not_fn() noexcept -> detail::stateless_not_fn< ConstFn >
Definition not_fn.hpp:92
constexpr auto not_fn(F &&f) -> detail::not_fn_t< etl::decay_t< F > >
Definition not_fn.hpp:86