Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
argument-tuple-accept.hpp
Go to the documentation of this file.
1/*
2 ARGUMENT-TUPLE-ACCEPT.hpp - helper template providing a bind(...) member function
3
4 Copyright (C)
5 2009, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
48#ifndef CONTROL_ARGUMENT_TUPLE_ACCEPT_H
49#define CONTROL_ARGUMENT_TUPLE_ACCEPT_H
50
51#include "lib/meta/typelist.hpp"
52#include "lib/meta/function.hpp"
54
55#include <utility>
56#include <tuple>
57
58
59
60namespace steam {
61namespace control {
62
63
64 namespace bind_arg { // internals....
65
66 using namespace lib::meta;
67 using std::make_tuple;
68
69
71 template< class TAR, class BA, class RET
72 , typename TYPES
73 >
74 struct AcceptArgs ;
75
76 template<class TAR, class BA, class RET, typename...ARGS>
77 struct AcceptArgs<TAR,BA,RET, Types<ARGS...> >
78 : BA
79 {
80 RET
82 {
83 return static_cast<TAR*> (this) -> bindArg (make_tuple (std::move(args) ...));
84 }
85 };
86
87
88
90 template< class TAR, class BA, class RET
91 , typename TYPES
92 >
93 struct AcceptBind ;
94
95 template<class TAR, class BA, class RET, typename...ARGS>
96 struct AcceptBind<TAR,BA,RET, Types<ARGS...> >
97 : BA
98 {
99 RET
100 bind (ARGS ...args)
101 {
102 return static_cast<TAR*> (this) -> bindArg (make_tuple (std::move(args)...));
103 }
104 };
105
106
107
108
109
112 template< class TAR, class BA, class RET>
114 : BA
115 {
117 RET
119 {
120 return static_cast<TAR*> (this) -> bindArg (std::tuple<>());
121 }
122
127 template<typename...ARGS>
128 RET
129 bind (ARGS&& ...args)
130 {
131 return static_cast<TAR*> (this) -> bindArg (make_tuple (std::forward<ARGS> (args)...));
132 }
133 };
134
135
136
137 using lib::meta::Tuple;
138 using lib::meta::_Fun;
139
140
141 template<typename SIG>
142 struct _Type
143 {
146 using Sig = SIG;
148 };
149
150 template<typename...TYPES>
151 struct _Type<std::tuple<TYPES...> >
152 {
153 using Args = Types<TYPES...>::Seq;
154 using Ret = void;
156 using ArgTuple = std::tuple<TYPES...>;
157 };
158
159 struct Dummy {};
160
161
162 } // (END) impl details (bind_arg)
163
164
165
166
173 template<typename SIG, class TAR, class BASE =bind_arg::Dummy>
175 : public bind_arg::AcceptArgs<TAR,BASE, typename bind_arg::_Type<SIG>::Ret
176 , typename bind_arg::_Type<SIG>::Args>
177 { };
178
179
185 template<typename SIG, class TAR, class BASE =bind_arg::Dummy>
187 : public bind_arg::AcceptBind<TAR,BASE, typename bind_arg::_Type<SIG>::Ret
188 , typename bind_arg::_Type<SIG>::Args>
189 { };
190
191
195 template<typename RET, typename SIG, class TAR, class BASE =bind_arg::Dummy>
197 : public bind_arg::AcceptBind<TAR,BASE, RET
198 , typename bind_arg::_Type<SIG>::Args>
199 { };
200
201
207 template< class TAR
208 , class RET =TAR&
209 , class BASE =bind_arg::Dummy
210 >
212 : public bind_arg::AcceptAnyBind<TAR,BASE,RET>
213 { };
214
215
216
217
218
219
220}} // namespace steam::control
221#endif
Helper Template for control::Command, mix-in complete set of bind(...) functions.
Variation of AcceptArgumentBinding, allowing to control the return type of the generated bind(....
Helper Template for Steam-Layer control::Command : mix in a bind(...) function.
Helper Template for building a Functor or function-like class: Mix in a function call operator,...
Metaprogramming tools for detecting and transforming function types.
BuildTupleType< TYPES >::Type Tuple
Build a std::tuple from types given as type sequence.
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
Build function types from given Argument types.
Definition function.hpp:236
variadic sequence of types
Definition typelist.hpp:102
STL namespace.
Steam-Layer implementation namespace root.
Trait template for uniform access to function signature types.
Definition function.hpp:144
RET bind(ARGS &&...args)
mix in bind function to create binding of arbitrary arguments
Metaprogramming with tuples-of-types and the std::tuple record.
A template metaprogramming technique for manipulating collections of types.