arg_router  1.4.0
C++ command line argument parsing and routing
router.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/policy/policy.hpp"
9 
10 #include <utility>
11 
12 namespace arg_router::policy
13 {
18 template <typename Fn>
19 class router
20 {
21 public:
23  using callable_type = Fn;
24 
29  constexpr explicit router(Fn f) noexcept : f_{std::move(f)} {}
30 
37  template <typename... Args>
38  void routing_phase(Args&&... args) const
39  {
40  f_(std::forward<Args>(args)...);
41  }
42 
43 private:
44  Fn f_;
45 };
46 
47 template <typename Fn>
48 struct is_policy<router<Fn>> : std::true_type {
49 };
50 } // namespace arg_router::policy
void routing_phase(Args &&... args) const
Definition: router.hpp:38
constexpr router(Fn f) noexcept
Definition: router.hpp:29