arg_router  1.4.0
C++ command line argument parsing and routing
required.hpp
1 // Copyright (C) 2022 by Camden Mannett.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
4 
5 #pragma once
6 
7 #include "arg_router/exception.hpp"
8 #include "arg_router/parsing/parsing.hpp"
9 #include "arg_router/policy/policy.hpp"
10 
11 #include <optional>
12 
13 namespace arg_router::policy
14 {
18 template <typename = void> // This is needed due so it can be used in
19 class required_t // template template parameters
20 {
21 public:
23  constexpr static auto priority = std::size_t{450};
24 
33  template <typename ValueType, typename... Parents>
34  [[noreturn]] ValueType missing_phase([[maybe_unused]] const Parents&... parents) const
35  {
36  static_assert(sizeof...(Parents) >= 1, "Alias requires at least 1 parent");
37 
38  using node_type = boost::mp11::mp_first<std::tuple<Parents...>>;
39 
41  parsing::node_token_type<node_type>()};
42  }
43 };
44 
46 constexpr auto required = required_t<>{};
47 
52 template <typename T>
53 using is_required = std::is_base_of<required_t<>, T>;
54 
59 template <typename T>
61 
62 template <>
63 struct is_policy<required_t<>> : std::true_type {
64 };
65 } // namespace arg_router::policy
constexpr static auto priority
Definition: required.hpp:23
ValueType missing_phase([[maybe_unused]] const Parents &... parents) const
Definition: required.hpp:34
constexpr auto required
Definition: required.hpp:46
constexpr bool is_required_v
Definition: required.hpp:60
std::is_base_of< required_t<>, T > is_required
Definition: required.hpp:53
@ missing_required_argument
A node has been marked as required but no token matches it.