Go to the documentation of this file.
15 #ifndef BELUGA_POLICIES_POLICY_HPP
16 #define BELUGA_POLICIES_POLICY_HPP
18 #include <type_traits>
23 template <
class PolicyFn>
30 struct make_policy_fn {
32 constexpr
policy<Fn> operator()(Fn&& fn)
const {
47 template <
class Left,
class Right>
49 return make_policy([=](
const auto&... args)
mutable ->
bool {
return left(args...) && right(args...); });
53 template <
class Left,
class Right>
55 return make_policy([=](
const auto&... args)
mutable ->
bool {
56 const bool first = left(args...);
57 const bool second = right(args...);
58 return first && second;
63 template <
class Left,
class Right>
65 return make_policy([=](
const auto&... args)
mutable ->
bool {
return left(args...) || right(args...); });
69 template <
class Left,
class Right>
71 return make_policy([=](
const auto&... args)
mutable ->
bool {
72 const bool first = left(args...);
73 const bool second = right(args...);
74 return first || second;
81 return make_policy([=](
const auto&... args)
mutable ->
bool {
return !fn(args...); });
101 template <
class PolicyFn>
102 struct policy :
public policy_base,
public PolicyFn {
107 constexpr
explicit policy(PolicyFn fn) : PolicyFn(
std::move(fn)) {}
109 using PolicyFn::PolicyFn;
110 using PolicyFn::operator=;
111 using PolicyFn::operator();
118 template <
class... Args>
121 std::is_invocable_r_v<bool, PolicyFn> && !std::is_invocable_r_v<bool, PolicyFn, Args...>,
128 template <
class... Args>
constexpr friend auto operator&&(policy< Left > left, policy< Right > right)
Short-circuited logical AND operation.
constexpr detail::make_policy_fn make_policy
Make policy function objects.
constexpr friend auto operator||(policy< Left > left, policy< Right > right)
Short-circuited logical OR operation.
constexpr friend auto operator!(policy< Fn > fn)
Logical NOT operation.
constexpr policy(PolicyFn fn)
Conversion constructor.
policy()=default
Default constructor.
constexpr friend auto operator&(policy< Left > left, policy< Right > right)
Non-short-circuited logical AND operation.
constexpr auto operator()(Args...) -> std::enable_if_t< std::is_invocable_r_v< bool, PolicyFn > &&!std::is_invocable_r_v< bool, PolicyFn, Args... >, bool >
Call operator overload.
Forward declaration of policy.
constexpr friend auto operator|(policy< Left > left, policy< Right > right)
Non-short-circuited logical OR operation.
Implementation detail for a policy base object.
The main Beluga namespace.
beluga
Author(s):
autogenerated on Tue Jul 16 2024 02:59:53