libcopp 2.3.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cmd_option_bind_param_list.h
Go to the documentation of this file.
1#ifndef UTIL_CLI_CMDOPTIONBINDPARAMLIST_H
2#define UTIL_CLI_CMDOPTIONBINDPARAMLIST_H
3
4#pragma once
5
6/*
7 * cmd_option_bind_param_list.h
8 *
9 * Created on: 2014-01-22
10 * Author: OWenT
11 *
12 * 绑定器参数列表类
13 */
14
17#include "cli/cmd_option_list.h"
18
19#include <tuple>
20
21namespace util {
22namespace cli {
23namespace binder {
24
29template <typename _Tp>
31 typedef _Tp type;
33
34 static const _Tp &do_wrap(const _Tp &__x) { return __x; }
35
36 static _Tp &do_wrap(_Tp &__x) { return __x; }
37};
38
43template <typename _Tp, typename _Class>
44struct maybe_wrap_member_pointer<_Tp _Class::*> {
45 typedef _Tp _Class::*type;
47
48 static type do_wrap(_Tp _Class::*__pm) { return type(__pm); }
49};
50
51// ============================
52// === 参数列表 ===
53// ============================
54template <typename... _Args>
56 private:
60 template <int... _Index>
62
63 template <std::size_t N, int... _Index>
64 struct build_args_index : build_args_index<N - 1, _Index..., sizeof...(_Index)> {};
65
66 template <int... _Index>
67 struct build_args_index<0, _Index...> {
68 typedef index_args_var_list<_Index...> type;
69 };
70
71 private:
72 template <class _F, int... _Indexes>
74 f(args, std::get<_Indexes>(args_)...);
75 }
76
77 private:
78 std::tuple<_Args...> args_;
79
80 public:
81 cmd_option_bind_param_list(_Args... args) : args_(args...) {}
82
83 template <class _F>
84 void operator()(_F &f, callback_param args, int) {
85 typedef typename build_args_index<sizeof...(_Args)>::type _index_type;
86 _do_call(f, args, _index_type());
87 }
88};
89
90} // namespace binder
91} // namespace cli
92} // namespace util
93#endif /* _CMDOPTIONBINDPARAMLIST_H_ */
void _do_call(_F &f, callback_param args, index_args_var_list< _Indexes... >)
void operator()(_F &f, callback_param args, int)