mn_stl.hpp
Go to the documentation of this file.
1 
19 #ifndef __MINILIB_STL_FUNCTIONS_H__
20 #define __MINILIB_STL_FUNCTIONS_H__
21 
22 namespace mn {
23  namespace stl {
24  template <typename T>
25  struct type_traits {
26  using value_type = T;
27  using const_type = const T;
28  using reference = T&;
29  using const_reference = const T&;
30  using pointer = T*;
31  using const_pointer = const T*;
32  };
33 
34  template <typename T>
35  struct type_traits<T&> {
36  using value_type = T;
37  using const_type = const T;
38  using reference = T&;
39  using const_reference = const T&;
40  using pointer = T*;
41  using const_pointer = const T*;
42  };
43 
44  template <typename T>
45  struct type_traits<const T> {
46  using value_type = T;
47  using const_type = const T;
48  using reference = T&;
49  using const_reference = const T&;
50  using pointer = T*;
51  using const_pointer = const T*;
52  };
53 
54  template <typename T>
55  struct type_traits<const T&> {
56  using value_type = T;
57  using const_type = const T;
58  using reference = T&;
59  using const_reference = const T&;
60  using pointer = T*;
61  using const_pointer = const T*;
62  };
63 
64 
65 
66  template<class T, T v> struct integral_constant {
67  enum { value = v };
68  };
69 
72 
73  template<typename Arg, typename TResult>
74  struct unary_function {
76  using argument_type = Arg;
78  using result_type = TResult;
79  };
80 
81 
82  template<typename Arg1, typename Arg2, typename TResult>
83  struct binary_function {
85  using first_argument_type = Arg;
87  using second_argument_type = Arg2;
89  using result_type = TResult;
90  };
91 
92  template<typename T>
93  struct negate : public unary_function<T, T> {
95  operator()(const T& a) const noexcept { return -a; }
96  };
97 
98  template<typename T>
99  struct plus : public binary_function<T, T, T> {
101  operator()(const T& a, const T& b) const noexcept { return a + b; }
102  };
103 
104  template<typename T>
105  struct minus : public binary_function<T, T, T> {
107  operator()(const T& a, const T& b) const noexcept { return a - b; }
108  };
109 
110  template<typename T>
111  struct multiplies : public binary_function<T, T, T> {
113  operator()(const T& a, const T& b) const noexcept { return a * b; }
114  };
115 
116  template<typename T>
117  struct divides : public binary_function<T, T, T> {
119  operator()(const T& a, const T& b) const noexcept { return a / b; }
120  };
121 
122  template<typename T>
123  struct modulus : public binary_function<T, T, T> {
125  operator()(const T& a, const T& b) const noexcept { return a % b; }
126  };
127 
128  template<typename T>
129  struct equal_to : public binary_function<T, T, bool> {
131  operator()(const T& a, const T& b) const noexcept { return a == b; }
132  };
133 
134  template<typename T>
135  struct not_equal_to : public binary_function<T, T, bool> {
137  operator()(const T& a, const T& b) const noexcept { return a != b; }
138  };
139 
140  template<typename T>
141  struct greater : public binary_function<T, T, bool> {
143  operator()(const T& a, const T& b) const noexcept { return a > b; }
144  };
145 
146  template<typename T>
147  struct less : public binary_function<T, T, bool> {
149  operator()(const T& a, const T& b) const noexcept { return a < b; }
150  };
151 
152  template<typename T>
153  struct greater_equal : public binary_function<T, T, bool> {
155  operator()(const T& a, const T& b) const noexcept { return a >= b; }
156  };
157 
158  template<typename T>
159  struct less_equal : public binary_function<T, T, bool> {
161  operator()(const T& a, const T& b) const noexcept { return a <= b; }
162  };
163 
164  template<typename T>
165  struct logic_and : public binary_function<T, T, bool> {
167  bool operator()(const T& a, const T& b) const noexcept { return a && b; }
168  };
169 
170  template<typename T>
171  struct logic_or : public binary_function<T, T, bool> {
173  operator()(const T& a, const T& b) const noexcept { return a || b; }
174  };
175 
176  template<typename T>
177  struct logic_not : public unary_function<T, bool> {
179  operator()(const T& a) const noexcept { return !a; }
180  };
181 
182  template<typename T>
183  struct bit_and : public binary_function<T, T, T> {
185  operator()(const T& a, const T& b) const noexcept { return a & b; }
186  };
187 
188  template<typename T>
189  struct bit_or : public binary_function<T, T, T> {
191  operator()(const T& a, const T& b) const noexcept { return a | b; }
192  };
193 
194  template<typename T>
195  struct bit_xor : public binary_function<T, T, T> {
197  operator()(const T& a, const T& b) const noexcept { return a ^ b; }
198  };
199 
200  template<typename T>
201  struct bit_not : public unary_function<T, T> {
203  operator()(const T& a) const noexcept { return ~a; }
204  };
205 
206 
207 
208  template <typename T>
209  struct is_reference : false_type { };
210 
211  template <typename T>
212  struct is_reference<T%> : true_type { };
213 
214  template <typename T>
215  struct is_reference<const T%> : true_type { };
216 
217  template <typename T>
218  struct is_const : false_type { };
219 
220  template <typename T>
221  struct is_const<const T> : true_type { };
222 
223  template <typename T>
224  struct is_const<const T&> : true_type { };
225 
226  template <typename T, int n>
227  struct is_const<const T[n]> : true_type { };
228 
229  template<typename>
230  struct is_volatile : public false_type { };
231 
232  template<typename _Tp>
233  struct is_volatile<_Tp volatile> : public true_type { };
234 
235  template<typename T>
236  struct is_empty : public integral_constant<bool, __is_empty(T)> { };
237 
238 
239  template<typename T>
240  struct is_enum : public integral_constant<bool, __is_enum(T)> { };
241 
242  template<typename T>
243  struct is_union : public integral_constant<bool, __is_union(T)> { };
244 
245  template<typename T>
246  struct is_class : public integral_constant<bool, __is_class(T)> { };
247 
248 
249  }
250 }
251 
252 #endif // __MINILIB_STL_FUNCTIONS_H__
struct mn::memory::detail::ptr_difference T
Definition: mn_atomic_singleton.hpp:38
const T & const_reference
Definition: mn_stl.hpp:39
T & reference
Definition: mn_stl.hpp:38
const T const_type
Definition: mn_stl.hpp:37
T value_type
Definition: mn_stl.hpp:26
T & reference
Definition: mn_stl.hpp:28
const T * const_pointer
Definition: mn_stl.hpp:31
const T & const_reference
Definition: mn_stl.hpp:49
TResult result_type
result_type is the return type
Definition: mn_stl.hpp:78
TResult result_type
result_type is the return type
Definition: mn_stl.hpp:89
T & reference
Definition: mn_stl.hpp:48
const T * const_pointer
Definition: mn_stl.hpp:61
T * pointer
Definition: mn_stl.hpp:40
const T & const_reference
Definition: mn_stl.hpp:29
Arg argument_type
argument_type is the type of the argument
Definition: mn_stl.hpp:76
const T const_type
Definition: mn_stl.hpp:27
const T * const_pointer
Definition: mn_stl.hpp:41
T * pointer
Definition: mn_stl.hpp:30
Arg first_argument_type
first_argument_type is the type of the first argument
Definition: mn_stl.hpp:85
T * pointer
Definition: mn_stl.hpp:50
Arg2 second_argument_type
second_argument_type is the type of the second argument
Definition: mn_stl.hpp:87
T value_type
Definition: mn_stl.hpp:56
T value_type
Definition: mn_stl.hpp:46
T & reference
Definition: mn_stl.hpp:58
const T const_type
Definition: mn_stl.hpp:57
const T * const_pointer
Definition: mn_stl.hpp:51
const T & const_reference
Definition: mn_stl.hpp:59
T value_type
Definition: mn_stl.hpp:36
T * pointer
Definition: mn_stl.hpp:60
const T const_type
Definition: mn_stl.hpp:47
Definition: mn_stl.hpp:83
Definition: mn_stl.hpp:25
Definition: mn_stl.hpp:74
Definition: mn_allocator_typetraits.hpp:25
Definition: mn_stl.hpp:183
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:185
Definition: mn_stl.hpp:201
binary_function< T, T, T >::result_type operator()(const T &a) const noexcept
Definition: mn_stl.hpp:203
Definition: mn_stl.hpp:189
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:191
Definition: mn_stl.hpp:195
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:197
Definition: mn_stl.hpp:117
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:119
Definition: mn_stl.hpp:129
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:131
Definition: mn_stl.hpp:153
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:155
Definition: mn_stl.hpp:141
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:143
Definition: mn_stl.hpp:66
@ value
Definition: mn_stl.hpp:67
Definition: mn_stl.hpp:246
Definition: mn_stl.hpp:218
Definition: mn_stl.hpp:236
Definition: mn_stl.hpp:240
Definition: mn_stl.hpp:209
Definition: mn_stl.hpp:243
Definition: mn_stl.hpp:230
Definition: mn_stl.hpp:159
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:161
Definition: mn_stl.hpp:147
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:149
Definition: mn_stl.hpp:165
binary_function< T, T, T >::result_type bool operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:167
Definition: mn_stl.hpp:177
binary_function< T, T, T >::result_type operator()(const T &a) const noexcept
Definition: mn_stl.hpp:179
Definition: mn_stl.hpp:171
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:173
Definition: mn_stl.hpp:105
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:107
Definition: mn_stl.hpp:123
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:125
Definition: mn_stl.hpp:111
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:113
Definition: mn_stl.hpp:93
binary_function< T, T, T >::result_type operator()(const T &a) const noexcept
Definition: mn_stl.hpp:95
Definition: mn_stl.hpp:135
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:137
Definition: mn_stl.hpp:99
binary_function< T, T, T >::result_type operator()(const T &a, const T &b) const noexcept
Definition: mn_stl.hpp:101