7 #include "arg_router/parsing/parsing.hpp"
8 #include "arg_router/policy/required.hpp"
23 template <
typename T =
void>
28 constexpr
static auto priority = std::size_t{800};
52 template <
typename ProcessedTarget,
typename... Parents>
57 [[maybe_unused]]
const Parents&... parents)
const
59 static_assert(
sizeof...(Parents) >= 1,
"Runtime enable requires at least 1 parent");
60 using node_type = boost::mp11::mp_first<std::tuple<Parents...>>;
61 static_assert(!policy::is_required_v<node_type>,
62 "Runtime enable must not be used with policy::required");
73 struct is_policy<runtime_enable<T>> : std::true_type {
77 class runtime_enable_required :
public runtime_enable<T>
93 explicit runtime_enable_required(
bool enable, T default_value = {}) noexcept :
94 runtime_enable<T>{enable}, default_value_{std::move(default_value)}
106 template <
typename ValueType,
typename... Parents>
107 [[nodiscard]] ValueType missing_phase([[maybe_unused]]
const Parents&... parents)
const
109 if (this->enabled_) {
110 static_assert(
sizeof...(Parents) >= 1,
"Runtime enable requires at least 1 parent");
111 using node_type = boost::mp11::mp_first<std::tuple<Parents...>>;
114 parsing::node_token_type<node_type>()};
117 return default_value_;
121 value_type default_value_;
124 template <
typename T>
125 struct is_policy<runtime_enable_required<T>> : std::true_type {
constexpr static auto priority
parsing::pre_parse_result pre_parse_phase([[maybe_unused]] parsing::dynamic_token_adapter &tokens, [[maybe_unused]] utility::compile_time_optional< ProcessedTarget > processed_target, [[maybe_unused]] parsing::parse_target &target, [[maybe_unused]] const Parents &... parents) const
bool runtime_enabled() const noexcept
runtime_enable(bool enable) noexcept
@ missing_required_argument
A node has been marked as required but no token matches it.