williamr@4
|
1 |
/*
|
williamr@4
|
2 |
* Copyright (c) 1999
|
williamr@4
|
3 |
* Silicon Graphics Computer Systems, Inc.
|
williamr@4
|
4 |
*
|
williamr@4
|
5 |
* Permission to use, copy, modify, distribute and sell this software
|
williamr@4
|
6 |
* and its documentation for any purpose is hereby granted without fee,
|
williamr@4
|
7 |
* provided that the above copyright notice appear in all copies and
|
williamr@4
|
8 |
* that both that copyright notice and this permission notice appear
|
williamr@4
|
9 |
* in supporting documentation. Silicon Graphics makes no
|
williamr@4
|
10 |
* representations about the suitability of this software for any
|
williamr@4
|
11 |
* purpose. It is provided "as is" without express or implied warranty.
|
williamr@4
|
12 |
*/
|
williamr@4
|
13 |
|
williamr@4
|
14 |
#ifndef __CONCEPT_CHECKS_H
|
williamr@4
|
15 |
#define __CONCEPT_CHECKS_H
|
williamr@4
|
16 |
|
williamr@4
|
17 |
/*
|
williamr@4
|
18 |
Use these macro like assertions, but they assert properties
|
williamr@4
|
19 |
on types (usually template arguments). In technical terms they
|
williamr@4
|
20 |
verify whether a type "models" a "concept".
|
williamr@4
|
21 |
|
williamr@4
|
22 |
This set of requirements and the terminology used here is derived
|
williamr@4
|
23 |
from the book "Generic Programming and the STL" by Matt Austern
|
williamr@4
|
24 |
(Addison Wesley). For further information please consult that
|
williamr@4
|
25 |
book. The requirements also are intended to match the ANSI/ISO C++
|
williamr@4
|
26 |
standard.
|
williamr@4
|
27 |
|
williamr@4
|
28 |
This file covers the basic concepts and the iterator concepts.
|
williamr@4
|
29 |
There are several other files that provide the requirements
|
williamr@4
|
30 |
for the STL containers:
|
williamr@4
|
31 |
container_concepts.h
|
williamr@4
|
32 |
sequence_concepts.h
|
williamr@4
|
33 |
assoc_container_concepts.h
|
williamr@4
|
34 |
|
williamr@4
|
35 |
Jeremy Siek, 1999
|
williamr@4
|
36 |
|
williamr@4
|
37 |
TO DO:
|
williamr@4
|
38 |
- some issues with regards to concept classification and mutability
|
williamr@4
|
39 |
including AssociativeContianer -> ForwardContainer
|
williamr@4
|
40 |
and SortedAssociativeContainer -> ReversibleContainer
|
williamr@4
|
41 |
- HashedAssociativeContainer
|
williamr@4
|
42 |
- Allocator
|
williamr@4
|
43 |
- Function Object Concepts
|
williamr@4
|
44 |
|
williamr@4
|
45 |
*/
|
williamr@4
|
46 |
|
williamr@4
|
47 |
#ifndef _STLP_USE_CONCEPT_CHECKS
|
williamr@4
|
48 |
|
williamr@4
|
49 |
// Some compilers lack the features that are necessary for concept checks.
|
williamr@4
|
50 |
// On those compilers we define the concept check macros to do nothing.
|
williamr@4
|
51 |
#define _STLP_REQUIRES(__type_var, __concept) do {} while(0)
|
williamr@4
|
52 |
#define _STLP_CLASS_REQUIRES(__type_var, __concept) \
|
williamr@4
|
53 |
static int __##__type_var##_##__concept
|
williamr@4
|
54 |
#define _STLP_CONVERTIBLE(__type_x, __type_y) do {} while(0)
|
williamr@4
|
55 |
#define _STLP_REQUIRES_SAME_TYPE(__type_x, __type_y) do {} while(0)
|
williamr@4
|
56 |
#define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \
|
williamr@4
|
57 |
static int __##__type_x##__type_y##_require_same_type
|
williamr@4
|
58 |
#define _STLP_GENERATOR_CHECK(__func, __ret) do {} while(0)
|
williamr@4
|
59 |
#define _STLP_CLASS_GENERATOR_CHECK(__func, __ret) \
|
williamr@4
|
60 |
static int __##__func##__ret##_generator_check
|
williamr@4
|
61 |
#define _STLP_UNARY_FUNCTION_CHECK(__func, __ret, __arg) do {} while(0)
|
williamr@4
|
62 |
#define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \
|
williamr@4
|
63 |
static int __##__func##__ret##__arg##_unary_function_check
|
williamr@4
|
64 |
#define _STLP_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
|
williamr@4
|
65 |
do {} while(0)
|
williamr@4
|
66 |
#define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
|
williamr@4
|
67 |
static int __##__func##__ret##__first##__second##_binary_function_check
|
williamr@4
|
68 |
#define _STLP_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
|
williamr@4
|
69 |
do {} while(0)
|
williamr@4
|
70 |
#define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
|
williamr@4
|
71 |
static int __##__opname##__ret##__first##__second##_require_binary_op
|
williamr@4
|
72 |
|
williamr@4
|
73 |
#else /* _STLP_USE_CONCEPT_CHECKS */
|
williamr@4
|
74 |
|
williamr@4
|
75 |
// This macro tests whether the template argument "__type_var"
|
williamr@4
|
76 |
// satisfies the requirements of "__concept". Here is a list of concepts
|
williamr@4
|
77 |
// that we know how to check:
|
williamr@4
|
78 |
// _Allocator
|
williamr@4
|
79 |
// _Assignable
|
williamr@4
|
80 |
// _DefaultConstructible
|
williamr@4
|
81 |
// _EqualityComparable
|
williamr@4
|
82 |
// _LessThanComparable
|
williamr@4
|
83 |
// _TrivialIterator
|
williamr@4
|
84 |
// _InputIterator
|
williamr@4
|
85 |
// _OutputIterator
|
williamr@4
|
86 |
// _ForwardIterator
|
williamr@4
|
87 |
// _BidirectionalIterator
|
williamr@4
|
88 |
// _RandomAccessIterator
|
williamr@4
|
89 |
// _Mutable_TrivialIterator
|
williamr@4
|
90 |
// _Mutable_ForwardIterator
|
williamr@4
|
91 |
// _Mutable_BidirectionalIterator
|
williamr@4
|
92 |
// _Mutable_RandomAccessIterator
|
williamr@4
|
93 |
|
williamr@4
|
94 |
#define _STLP_REQUIRES(__type_var, __concept) \
|
williamr@4
|
95 |
do { \
|
williamr@4
|
96 |
void (*__x)( __type_var ) = __concept##_concept_specification< __type_var >\
|
williamr@4
|
97 |
::##__concept##_requirement_violation; __x = __x; } while (0)
|
williamr@4
|
98 |
|
williamr@4
|
99 |
// Use this to check whether type X is convertible to type Y
|
williamr@4
|
100 |
#define _STLP_CONVERTIBLE(__type_x, __type_y) \
|
williamr@4
|
101 |
do { \
|
williamr@4
|
102 |
void (*__x)( __type_x , __type_y ) = _STL_CONVERT_ERROR< __type_x , \
|
williamr@4
|
103 |
__type_y >::__type_X_is_not_convertible_to_type_Y; \
|
williamr@4
|
104 |
__x = __x; } while (0)
|
williamr@4
|
105 |
|
williamr@4
|
106 |
// Use this to test whether two template arguments are the same type
|
williamr@4
|
107 |
#define _STLP_REQUIRES_SAME_TYPE(__type_x, __type_y) \
|
williamr@4
|
108 |
do { \
|
williamr@4
|
109 |
void (*__x)( __type_x , __type_y ) = _STL_SAME_TYPE_ERROR< __type_x, \
|
williamr@4
|
110 |
__type_y >::__type_X_not_same_as_type_Y; \
|
williamr@4
|
111 |
__x = __x; } while (0)
|
williamr@4
|
112 |
|
williamr@4
|
113 |
|
williamr@4
|
114 |
// function object checks
|
williamr@4
|
115 |
#define _STLP_GENERATOR_CHECK(__func, __ret) \
|
williamr@4
|
116 |
do { \
|
williamr@4
|
117 |
__ret (*__x)( __func&) = \
|
williamr@4
|
118 |
_STL_GENERATOR_ERROR< \
|
williamr@4
|
119 |
__func, __ret>::__generator_requirement_violation; \
|
williamr@4
|
120 |
__x = __x; } while (0)
|
williamr@4
|
121 |
|
williamr@4
|
122 |
|
williamr@4
|
123 |
#define _STLP_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \
|
williamr@4
|
124 |
do { \
|
williamr@4
|
125 |
__ret (*__x)( __func&, const __arg& ) = \
|
williamr@4
|
126 |
_STL_UNARY_FUNCTION_ERROR< \
|
williamr@4
|
127 |
__func, __ret, __arg>::__unary_function_requirement_violation; \
|
williamr@4
|
128 |
__x = __x; } while (0)
|
williamr@4
|
129 |
|
williamr@4
|
130 |
|
williamr@4
|
131 |
#define _STLP_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
|
williamr@4
|
132 |
do { \
|
williamr@4
|
133 |
__ret (*__x)( __func&, const __first&, const __second& ) = \
|
williamr@4
|
134 |
_STL_BINARY_FUNCTION_ERROR< \
|
williamr@4
|
135 |
__func, __ret, __first, __second>::__binary_function_requirement_violation; \
|
williamr@4
|
136 |
__x = __x; } while (0)
|
williamr@4
|
137 |
|
williamr@4
|
138 |
|
williamr@4
|
139 |
#define _STLP_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
|
williamr@4
|
140 |
do { \
|
williamr@4
|
141 |
__ret (*__x)( __first&, __second& ) = _STL_BINARY##__opname##_ERROR< \
|
williamr@4
|
142 |
__ret, __first, __second>::__binary_operator_requirement_violation; \
|
williamr@4
|
143 |
__ret (*__y)( const __first&, const __second& ) = \
|
williamr@4
|
144 |
_STL_BINARY##__opname##_ERROR< __ret, __first, __second>:: \
|
williamr@4
|
145 |
__const_binary_operator_requirement_violation; \
|
williamr@4
|
146 |
__y = __y; __x = __x; } while (0)
|
williamr@4
|
147 |
|
williamr@4
|
148 |
|
williamr@4
|
149 |
#ifdef _STLP_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE
|
williamr@4
|
150 |
|
williamr@4
|
151 |
#define _STLP_CLASS_REQUIRES(__type_var, __concept)
|
williamr@4
|
152 |
#define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y)
|
williamr@4
|
153 |
#define _STLP_CLASS_GENERATOR_CHECK(__func, __ret)
|
williamr@4
|
154 |
#define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg)
|
williamr@4
|
155 |
#define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second)
|
williamr@4
|
156 |
#define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second)
|
williamr@4
|
157 |
|
williamr@4
|
158 |
#else
|
williamr@4
|
159 |
|
williamr@4
|
160 |
// Use this macro inside of template classes, where you would
|
williamr@4
|
161 |
// like to place requirements on the template arguments to the class
|
williamr@4
|
162 |
// Warning: do not pass pointers and such (e.g. T*) in as the __type_var,
|
williamr@4
|
163 |
// since the type_var is used to construct identifiers. Instead typedef
|
williamr@4
|
164 |
// the pointer type, then use the typedef name for the __type_var.
|
williamr@4
|
165 |
#define _STLP_CLASS_REQUIRES(__type_var, __concept) \
|
williamr@4
|
166 |
typedef void (* __func##__type_var##__concept)( __type_var ); \
|
williamr@4
|
167 |
template <__func##__type_var##__concept _Tp1> \
|
williamr@4
|
168 |
struct __dummy_struct_##__type_var##__concept { }; \
|
williamr@4
|
169 |
static __dummy_struct_##__type_var##__concept< \
|
williamr@4
|
170 |
__concept##_concept_specification< \
|
williamr@4
|
171 |
__type_var>::__concept##_requirement_violation> \
|
williamr@4
|
172 |
__dummy_ptr_##__type_var##__concept
|
williamr@4
|
173 |
|
williamr@4
|
174 |
|
williamr@4
|
175 |
#define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \
|
williamr@4
|
176 |
typedef void (* __func_##__type_x##__type_y##same_type)( __type_x, \
|
williamr@4
|
177 |
__type_y ); \
|
williamr@4
|
178 |
template < __func_##__type_x##__type_y##same_type _Tp1> \
|
williamr@4
|
179 |
struct __dummy_struct_##__type_x##__type_y##_same_type { }; \
|
williamr@4
|
180 |
static __dummy_struct_##__type_x##__type_y##_same_type< \
|
williamr@4
|
181 |
_STL_SAME_TYPE_ERROR<__type_x, __type_y>::__type_X_not_same_as_type_Y> \
|
williamr@4
|
182 |
__dummy_ptr_##__type_x##__type_y##_same_type
|
williamr@4
|
183 |
|
williamr@4
|
184 |
|
williamr@4
|
185 |
#define _STLP_CLASS_GENERATOR_CHECK(__func, __ret) \
|
williamr@4
|
186 |
typedef __ret (* __f_##__func##__ret##_generator)( __func& ); \
|
williamr@4
|
187 |
template <__f_##__func##__ret##_generator _Tp1> \
|
williamr@4
|
188 |
struct __dummy_struct_##__func##__ret##_generator { }; \
|
williamr@4
|
189 |
static __dummy_struct_##__func##__ret##_generator< \
|
williamr@4
|
190 |
_STL_GENERATOR_ERROR< \
|
williamr@4
|
191 |
__func, __ret>::__generator_requirement_violation> \
|
williamr@4
|
192 |
__dummy_ptr_##__func##__ret##_generator
|
williamr@4
|
193 |
|
williamr@4
|
194 |
|
williamr@4
|
195 |
#define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \
|
williamr@4
|
196 |
typedef __ret (* __f_##__func##__ret##__arg##_unary_check)( __func&, \
|
williamr@4
|
197 |
const __arg& ); \
|
williamr@4
|
198 |
template <__f_##__func##__ret##__arg##_unary_check _Tp1> \
|
williamr@4
|
199 |
struct __dummy_struct_##__func##__ret##__arg##_unary_check { }; \
|
williamr@4
|
200 |
static __dummy_struct_##__func##__ret##__arg##_unary_check< \
|
williamr@4
|
201 |
_STL_UNARY_FUNCTION_ERROR< \
|
williamr@4
|
202 |
__func, __ret, __arg>::__unary_function_requirement_violation> \
|
williamr@4
|
203 |
__dummy_ptr_##__func##__ret##__arg##_unary_check
|
williamr@4
|
204 |
|
williamr@4
|
205 |
|
williamr@4
|
206 |
#define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
|
williamr@4
|
207 |
typedef __ret (* __f_##__func##__ret##__first##__second##_binary_check)( __func&, const __first&,\
|
williamr@4
|
208 |
const __second& ); \
|
williamr@4
|
209 |
template <__f_##__func##__ret##__first##__second##_binary_check _Tp1> \
|
williamr@4
|
210 |
struct __dummy_struct_##__func##__ret##__first##__second##_binary_check { }; \
|
williamr@4
|
211 |
static __dummy_struct_##__func##__ret##__first##__second##_binary_check< \
|
williamr@4
|
212 |
_STL_BINARY_FUNCTION_ERROR<__func, __ret, __first, __second>:: \
|
williamr@4
|
213 |
__binary_function_requirement_violation> \
|
williamr@4
|
214 |
__dummy_ptr_##__func##__ret##__first##__second##_binary_check
|
williamr@4
|
215 |
|
williamr@4
|
216 |
|
williamr@4
|
217 |
#define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
|
williamr@4
|
218 |
typedef __ret (* __f_##__func##__ret##__first##__second##_binary_op)(const __first&, \
|
williamr@4
|
219 |
const __second& ); \
|
williamr@4
|
220 |
template <__f_##__func##__ret##__first##__second##_binary_op _Tp1> \
|
williamr@4
|
221 |
struct __dummy_struct_##__func##__ret##__first##__second##_binary_op { }; \
|
williamr@4
|
222 |
static __dummy_struct_##__func##__ret##__first##__second##_binary_op< \
|
williamr@4
|
223 |
_STL_BINARY##__opname##_ERROR<__ret, __first, __second>:: \
|
williamr@4
|
224 |
__binary_operator_requirement_violation> \
|
williamr@4
|
225 |
__dummy_ptr_##__func##__ret##__first##__second##_binary_op
|
williamr@4
|
226 |
|
williamr@4
|
227 |
#endif
|
williamr@4
|
228 |
|
williamr@4
|
229 |
/* helper class for finding non-const version of a type. Need to have
|
williamr@4
|
230 |
something to assign to etc. when testing constant iterators. */
|
williamr@4
|
231 |
|
williamr@4
|
232 |
template <class _Tp>
|
williamr@4
|
233 |
struct _Mutable_trait {
|
williamr@4
|
234 |
typedef _Tp _Type;
|
williamr@4
|
235 |
};
|
williamr@4
|
236 |
template <class _Tp>
|
williamr@4
|
237 |
struct _Mutable_trait<const _Tp> {
|
williamr@4
|
238 |
typedef _Tp _Type;
|
williamr@4
|
239 |
};
|
williamr@4
|
240 |
|
williamr@4
|
241 |
|
williamr@4
|
242 |
/* helper function for avoiding compiler warnings about unused variables */
|
williamr@4
|
243 |
template <class _Type>
|
williamr@4
|
244 |
void __sink_unused_warning(_Type) { }
|
williamr@4
|
245 |
|
williamr@4
|
246 |
template <class _TypeX, class _TypeY>
|
williamr@4
|
247 |
struct _STL_CONVERT_ERROR {
|
williamr@4
|
248 |
static void
|
williamr@4
|
249 |
__type_X_is_not_convertible_to_type_Y(_TypeX __x, _TypeY) {
|
williamr@4
|
250 |
_TypeY __y = __x;
|
williamr@4
|
251 |
__sink_unused_warning(__y);
|
williamr@4
|
252 |
}
|
williamr@4
|
253 |
};
|
williamr@4
|
254 |
|
williamr@4
|
255 |
|
williamr@4
|
256 |
template <class _Type> struct __check_equal { };
|
williamr@4
|
257 |
|
williamr@4
|
258 |
template <class _TypeX, class _TypeY>
|
williamr@4
|
259 |
struct _STL_SAME_TYPE_ERROR {
|
williamr@4
|
260 |
static void
|
williamr@4
|
261 |
__type_X_not_same_as_type_Y(_TypeX , _TypeY ) {
|
williamr@4
|
262 |
__check_equal<_TypeX> t1 = __check_equal<_TypeY>();
|
williamr@4
|
263 |
}
|
williamr@4
|
264 |
};
|
williamr@4
|
265 |
|
williamr@4
|
266 |
|
williamr@4
|
267 |
// Some Functon Object Checks
|
williamr@4
|
268 |
|
williamr@4
|
269 |
template <class _Func, class _Ret>
|
williamr@4
|
270 |
struct _STL_GENERATOR_ERROR {
|
williamr@4
|
271 |
static _Ret __generator_requirement_violation(_Func& __f) {
|
williamr@4
|
272 |
return __f();
|
williamr@4
|
273 |
}
|
williamr@4
|
274 |
};
|
williamr@4
|
275 |
|
williamr@4
|
276 |
template <class _Func>
|
williamr@4
|
277 |
struct _STL_GENERATOR_ERROR<_Func, void> {
|
williamr@4
|
278 |
static void __generator_requirement_violation(_Func& __f) {
|
williamr@4
|
279 |
__f();
|
williamr@4
|
280 |
}
|
williamr@4
|
281 |
};
|
williamr@4
|
282 |
|
williamr@4
|
283 |
|
williamr@4
|
284 |
template <class _Func, class _Ret, class _Arg>
|
williamr@4
|
285 |
struct _STL_UNARY_FUNCTION_ERROR {
|
williamr@4
|
286 |
static _Ret
|
williamr@4
|
287 |
__unary_function_requirement_violation(_Func& __f,
|
williamr@4
|
288 |
const _Arg& __arg) {
|
williamr@4
|
289 |
return __f(__arg);
|
williamr@4
|
290 |
}
|
williamr@4
|
291 |
};
|
williamr@4
|
292 |
|
williamr@4
|
293 |
template <class _Func, class _Arg>
|
williamr@4
|
294 |
struct _STL_UNARY_FUNCTION_ERROR<_Func, void, _Arg> {
|
williamr@4
|
295 |
static void
|
williamr@4
|
296 |
__unary_function_requirement_violation(_Func& __f,
|
williamr@4
|
297 |
const _Arg& __arg) {
|
williamr@4
|
298 |
__f(__arg);
|
williamr@4
|
299 |
}
|
williamr@4
|
300 |
};
|
williamr@4
|
301 |
|
williamr@4
|
302 |
template <class _Func, class _Ret, class _First, class _Second>
|
williamr@4
|
303 |
struct _STL_BINARY_FUNCTION_ERROR {
|
williamr@4
|
304 |
static _Ret
|
williamr@4
|
305 |
__binary_function_requirement_violation(_Func& __f,
|
williamr@4
|
306 |
const _First& __first,
|
williamr@4
|
307 |
const _Second& __second) {
|
williamr@4
|
308 |
return __f(__first, __second);
|
williamr@4
|
309 |
}
|
williamr@4
|
310 |
};
|
williamr@4
|
311 |
|
williamr@4
|
312 |
template <class _Func, class _First, class _Second>
|
williamr@4
|
313 |
struct _STL_BINARY_FUNCTION_ERROR<_Func, void, _First, _Second> {
|
williamr@4
|
314 |
static void
|
williamr@4
|
315 |
__binary_function_requirement_violation(_Func& __f,
|
williamr@4
|
316 |
const _First& __first,
|
williamr@4
|
317 |
const _Second& __second) {
|
williamr@4
|
318 |
__f(__first, __second);
|
williamr@4
|
319 |
}
|
williamr@4
|
320 |
};
|
williamr@4
|
321 |
|
williamr@4
|
322 |
|
williamr@4
|
323 |
#define _STLP_DEFINE_BINARY_OP_CHECK(_OP, _NAME) \
|
williamr@4
|
324 |
template <class _Ret, class _First, class _Second> \
|
williamr@4
|
325 |
struct _STL_BINARY##_NAME##_ERROR { \
|
williamr@4
|
326 |
static _Ret \
|
williamr@4
|
327 |
__const_binary_operator_requirement_violation(const _First& __first, \
|
williamr@4
|
328 |
const _Second& __second) { \
|
williamr@4
|
329 |
return __first _OP __second; \
|
williamr@4
|
330 |
} \
|
williamr@4
|
331 |
static _Ret \
|
williamr@4
|
332 |
__binary_operator_requirement_violation(_First& __first, \
|
williamr@4
|
333 |
_Second& __second) { \
|
williamr@4
|
334 |
return __first _OP __second; \
|
williamr@4
|
335 |
} \
|
williamr@4
|
336 |
}
|
williamr@4
|
337 |
|
williamr@4
|
338 |
_STLP_DEFINE_BINARY_OP_CHECK(==, _OP_EQUAL);
|
williamr@4
|
339 |
_STLP_DEFINE_BINARY_OP_CHECK(!=, _OP_NOT_EQUAL);
|
williamr@4
|
340 |
_STLP_DEFINE_BINARY_OP_CHECK(<, _OP_LESS_THAN);
|
williamr@4
|
341 |
_STLP_DEFINE_BINARY_OP_CHECK(<=, _OP_LESS_EQUAL);
|
williamr@4
|
342 |
_STLP_DEFINE_BINARY_OP_CHECK(>, _OP_GREATER_THAN);
|
williamr@4
|
343 |
_STLP_DEFINE_BINARY_OP_CHECK(>=, _OP_GREATER_EQUAL);
|
williamr@4
|
344 |
_STLP_DEFINE_BINARY_OP_CHECK(+, _OP_PLUS);
|
williamr@4
|
345 |
_STLP_DEFINE_BINARY_OP_CHECK(*, _OP_TIMES);
|
williamr@4
|
346 |
_STLP_DEFINE_BINARY_OP_CHECK(/, _OP_DIVIDE);
|
williamr@4
|
347 |
_STLP_DEFINE_BINARY_OP_CHECK(-, _OP_SUBTRACT);
|
williamr@4
|
348 |
_STLP_DEFINE_BINARY_OP_CHECK(%, _OP_MOD);
|
williamr@4
|
349 |
// ...
|
williamr@4
|
350 |
|
williamr@4
|
351 |
// TODO, add unary operators (prefix and postfix)
|
williamr@4
|
352 |
|
williamr@4
|
353 |
/*
|
williamr@4
|
354 |
The presence of this class is just to trick EDG into displaying
|
williamr@4
|
355 |
these error messages before any other errors. Without the
|
williamr@4
|
356 |
classes, the errors in the functions get reported after
|
williamr@4
|
357 |
other class errors deep inside the library. The name
|
williamr@4
|
358 |
choice just makes for an eye catching error message :)
|
williamr@4
|
359 |
*/
|
williamr@4
|
360 |
struct _STL_ERROR {
|
williamr@4
|
361 |
|
williamr@4
|
362 |
template <class _Type>
|
williamr@4
|
363 |
static _Type
|
williamr@4
|
364 |
__default_constructor_requirement_violation(_Type) {
|
williamr@4
|
365 |
return _Type();
|
williamr@4
|
366 |
}
|
williamr@4
|
367 |
template <class _Type>
|
williamr@4
|
368 |
static _Type
|
williamr@4
|
369 |
__assignment_operator_requirement_violation(_Type __a) {
|
williamr@4
|
370 |
__a = __a;
|
williamr@4
|
371 |
return __a;
|
williamr@4
|
372 |
}
|
williamr@4
|
373 |
template <class _Type>
|
williamr@4
|
374 |
static _Type
|
williamr@4
|
375 |
__copy_constructor_requirement_violation(_Type __a) {
|
williamr@4
|
376 |
_Type __c(__a);
|
williamr@4
|
377 |
return __c;
|
williamr@4
|
378 |
}
|
williamr@4
|
379 |
template <class _Type>
|
williamr@4
|
380 |
static _Type
|
williamr@4
|
381 |
__const_parameter_required_for_copy_constructor(_Type /* __a */,
|
williamr@4
|
382 |
const _Type& __b) {
|
williamr@4
|
383 |
_Type __c(__b);
|
williamr@4
|
384 |
return __c;
|
williamr@4
|
385 |
}
|
williamr@4
|
386 |
template <class _Type>
|
williamr@4
|
387 |
static _Type
|
williamr@4
|
388 |
__const_parameter_required_for_assignment_operator(_Type __a,
|
williamr@4
|
389 |
const _Type& __b) {
|
williamr@4
|
390 |
__a = __b;
|
williamr@4
|
391 |
return __a;
|
williamr@4
|
392 |
}
|
williamr@4
|
393 |
template <class _Type>
|
williamr@4
|
394 |
static _Type
|
williamr@4
|
395 |
__less_than_comparable_requirement_violation(_Type __a, _Type __b) {
|
williamr@4
|
396 |
if (__a < __b || __a > __b || __a <= __b || __a >= __b) return __a;
|
williamr@4
|
397 |
return __b;
|
williamr@4
|
398 |
}
|
williamr@4
|
399 |
template <class _Type>
|
williamr@4
|
400 |
static _Type
|
williamr@4
|
401 |
__equality_comparable_requirement_violation(_Type __a, _Type __b) {
|
williamr@4
|
402 |
if (__a == __b || __a != __b) return __a;
|
williamr@4
|
403 |
return __b;
|
williamr@4
|
404 |
}
|
williamr@4
|
405 |
template <class _Iterator>
|
williamr@4
|
406 |
static void
|
williamr@4
|
407 |
__dereference_operator_requirement_violation(_Iterator __i) {
|
williamr@4
|
408 |
__sink_unused_warning(*__i);
|
williamr@4
|
409 |
}
|
williamr@4
|
410 |
template <class _Iterator>
|
williamr@4
|
411 |
static void
|
williamr@4
|
412 |
__dereference_operator_and_assignment_requirement_violation(_Iterator __i) {
|
williamr@4
|
413 |
*__i = *__i;
|
williamr@4
|
414 |
}
|
williamr@4
|
415 |
template <class _Iterator>
|
williamr@4
|
416 |
static void
|
williamr@4
|
417 |
__preincrement_operator_requirement_violation(_Iterator __i) {
|
williamr@4
|
418 |
++__i;
|
williamr@4
|
419 |
}
|
williamr@4
|
420 |
template <class _Iterator>
|
williamr@4
|
421 |
static void
|
williamr@4
|
422 |
__postincrement_operator_requirement_violation(_Iterator __i) {
|
williamr@4
|
423 |
__i++;
|
williamr@4
|
424 |
}
|
williamr@4
|
425 |
template <class _Iterator>
|
williamr@4
|
426 |
static void
|
williamr@4
|
427 |
__predecrement_operator_requirement_violation(_Iterator __i) {
|
williamr@4
|
428 |
--__i;
|
williamr@4
|
429 |
}
|
williamr@4
|
430 |
template <class _Iterator>
|
williamr@4
|
431 |
static void
|
williamr@4
|
432 |
__postdecrement_operator_requirement_violation(_Iterator __i) {
|
williamr@4
|
433 |
__i--;
|
williamr@4
|
434 |
}
|
williamr@4
|
435 |
template <class _Iterator, class _Type>
|
williamr@4
|
436 |
static void
|
williamr@4
|
437 |
__postincrement_operator_and_assignment_requirement_violation(_Iterator __i,
|
williamr@4
|
438 |
_Type __t) {
|
williamr@4
|
439 |
*__i++ = __t;
|
williamr@4
|
440 |
}
|
williamr@4
|
441 |
template <class _Iterator, class _Distance>
|
williamr@4
|
442 |
static _Iterator
|
williamr@4
|
443 |
__iterator_addition_assignment_requirement_violation(_Iterator __i,
|
williamr@4
|
444 |
_Distance __n) {
|
williamr@4
|
445 |
__i += __n;
|
williamr@4
|
446 |
return __i;
|
williamr@4
|
447 |
}
|
williamr@4
|
448 |
template <class _Iterator, class _Distance>
|
williamr@4
|
449 |
static _Iterator
|
williamr@4
|
450 |
__iterator_addition_requirement_violation(_Iterator __i, _Distance __n) {
|
williamr@4
|
451 |
__i = __i + __n;
|
williamr@4
|
452 |
__i = __n + __i;
|
williamr@4
|
453 |
return __i;
|
williamr@4
|
454 |
}
|
williamr@4
|
455 |
template <class _Iterator, class _Distance>
|
williamr@4
|
456 |
static _Iterator
|
williamr@4
|
457 |
__iterator_subtraction_assignment_requirement_violation(_Iterator __i,
|
williamr@4
|
458 |
_Distance __n) {
|
williamr@4
|
459 |
__i -= __n;
|
williamr@4
|
460 |
return __i;
|
williamr@4
|
461 |
}
|
williamr@4
|
462 |
template <class _Iterator, class _Distance>
|
williamr@4
|
463 |
static _Iterator
|
williamr@4
|
464 |
__iterator_subtraction_requirement_violation(_Iterator __i, _Distance __n) {
|
williamr@4
|
465 |
__i = __i - __n;
|
williamr@4
|
466 |
return __i;
|
williamr@4
|
467 |
}
|
williamr@4
|
468 |
template <class _Iterator, class _Distance>
|
williamr@4
|
469 |
static _Distance
|
williamr@4
|
470 |
__difference_operator_requirement_violation(_Iterator __i, _Iterator __j,
|
williamr@4
|
471 |
_Distance __n) {
|
williamr@4
|
472 |
__n = __i - __j;
|
williamr@4
|
473 |
return __n;
|
williamr@4
|
474 |
}
|
williamr@4
|
475 |
template <class _Exp, class _Type, class _Distance>
|
williamr@4
|
476 |
static _Type
|
williamr@4
|
477 |
__element_access_operator_requirement_violation(_Exp __x, _Type*,
|
williamr@4
|
478 |
_Distance __n) {
|
williamr@4
|
479 |
return __x[__n];
|
williamr@4
|
480 |
}
|
williamr@4
|
481 |
template <class _Exp, class _Type, class _Distance>
|
williamr@4
|
482 |
static void
|
williamr@4
|
483 |
__element_assignment_operator_requirement_violation(_Exp __x,
|
williamr@4
|
484 |
_Type* __t,
|
williamr@4
|
485 |
_Distance __n) {
|
williamr@4
|
486 |
__x[__n] = *__t;
|
williamr@4
|
487 |
}
|
williamr@4
|
488 |
|
williamr@4
|
489 |
}; /* _STL_ERROR */
|
williamr@4
|
490 |
|
williamr@4
|
491 |
/* Associated Type Requirements */
|
williamr@4
|
492 |
|
williamr@4
|
493 |
_STLP_BEGIN_NAMESPACE
|
williamr@4
|
494 |
template <class _Iterator> struct iterator_traits;
|
williamr@4
|
495 |
_STLP_END_NAMESPACE
|
williamr@4
|
496 |
|
williamr@4
|
497 |
template <class _Iter>
|
williamr@4
|
498 |
struct __value_type_type_definition_requirement_violation {
|
williamr@4
|
499 |
typedef typename __STD::iterator_traits<_Iter>::value_type value_type;
|
williamr@4
|
500 |
};
|
williamr@4
|
501 |
|
williamr@4
|
502 |
template <class _Iter>
|
williamr@4
|
503 |
struct __difference_type_type_definition_requirement_violation {
|
williamr@4
|
504 |
typedef typename __STD::iterator_traits<_Iter>::difference_type
|
williamr@4
|
505 |
difference_type;
|
williamr@4
|
506 |
};
|
williamr@4
|
507 |
|
williamr@4
|
508 |
template <class _Iter>
|
williamr@4
|
509 |
struct __reference_type_definition_requirement_violation {
|
williamr@4
|
510 |
typedef typename __STD::iterator_traits<_Iter>::reference reference;
|
williamr@4
|
511 |
};
|
williamr@4
|
512 |
|
williamr@4
|
513 |
template <class _Iter>
|
williamr@4
|
514 |
struct __pointer_type_definition_requirement_violation {
|
williamr@4
|
515 |
typedef typename __STD::iterator_traits<_Iter>::pointer pointer;
|
williamr@4
|
516 |
};
|
williamr@4
|
517 |
|
williamr@4
|
518 |
template <class _Iter>
|
williamr@4
|
519 |
struct __iterator_category_type_definition_requirement_violation {
|
williamr@4
|
520 |
typedef typename __STD::iterator_traits<_Iter>::iterator_category
|
williamr@4
|
521 |
iterator_category;
|
williamr@4
|
522 |
};
|
williamr@4
|
523 |
|
williamr@4
|
524 |
/* Assignable Requirements */
|
williamr@4
|
525 |
|
williamr@4
|
526 |
|
williamr@4
|
527 |
template <class _Type>
|
williamr@4
|
528 |
struct _Assignable_concept_specification {
|
williamr@4
|
529 |
static void _Assignable_requirement_violation(_Type __a) {
|
williamr@4
|
530 |
_STL_ERROR::__assignment_operator_requirement_violation(__a);
|
williamr@4
|
531 |
_STL_ERROR::__copy_constructor_requirement_violation(__a);
|
williamr@4
|
532 |
_STL_ERROR::__const_parameter_required_for_copy_constructor(__a,__a);
|
williamr@4
|
533 |
_STL_ERROR::__const_parameter_required_for_assignment_operator(__a,__a);
|
williamr@4
|
534 |
}
|
williamr@4
|
535 |
};
|
williamr@4
|
536 |
|
williamr@4
|
537 |
/* DefaultConstructible Requirements */
|
williamr@4
|
538 |
|
williamr@4
|
539 |
|
williamr@4
|
540 |
template <class _Type>
|
williamr@4
|
541 |
struct _DefaultConstructible_concept_specification {
|
williamr@4
|
542 |
static void _DefaultConstructible_requirement_violation(_Type __a) {
|
williamr@4
|
543 |
_STL_ERROR::__default_constructor_requirement_violation(__a);
|
williamr@4
|
544 |
}
|
williamr@4
|
545 |
};
|
williamr@4
|
546 |
|
williamr@4
|
547 |
/* EqualityComparable Requirements */
|
williamr@4
|
548 |
|
williamr@4
|
549 |
template <class _Type>
|
williamr@4
|
550 |
struct _EqualityComparable_concept_specification {
|
williamr@4
|
551 |
static void _EqualityComparable_requirement_violation(_Type __a) {
|
williamr@4
|
552 |
_STL_ERROR::__equality_comparable_requirement_violation(__a, __a);
|
williamr@4
|
553 |
}
|
williamr@4
|
554 |
};
|
williamr@4
|
555 |
|
williamr@4
|
556 |
/* LessThanComparable Requirements */
|
williamr@4
|
557 |
template <class _Type>
|
williamr@4
|
558 |
struct _LessThanComparable_concept_specification {
|
williamr@4
|
559 |
static void _LessThanComparable_requirement_violation(_Type __a) {
|
williamr@4
|
560 |
_STL_ERROR::__less_than_comparable_requirement_violation(__a, __a);
|
williamr@4
|
561 |
}
|
williamr@4
|
562 |
};
|
williamr@4
|
563 |
|
williamr@4
|
564 |
/* TrivialIterator Requirements */
|
williamr@4
|
565 |
|
williamr@4
|
566 |
template <class _TrivialIterator>
|
williamr@4
|
567 |
struct _TrivialIterator_concept_specification {
|
williamr@4
|
568 |
static void
|
williamr@4
|
569 |
_TrivialIterator_requirement_violation(_TrivialIterator __i) {
|
williamr@4
|
570 |
typedef typename
|
williamr@4
|
571 |
__value_type_type_definition_requirement_violation<_TrivialIterator>::
|
williamr@4
|
572 |
value_type __T;
|
williamr@4
|
573 |
// Refinement of Assignable
|
williamr@4
|
574 |
_Assignable_concept_specification<_TrivialIterator>::
|
williamr@4
|
575 |
_Assignable_requirement_violation(__i);
|
williamr@4
|
576 |
// Refinement of DefaultConstructible
|
williamr@4
|
577 |
_DefaultConstructible_concept_specification<_TrivialIterator>::
|
williamr@4
|
578 |
_DefaultConstructible_requirement_violation(__i);
|
williamr@4
|
579 |
// Refinement of EqualityComparable
|
williamr@4
|
580 |
_EqualityComparable_concept_specification<_TrivialIterator>::
|
williamr@4
|
581 |
_EqualityComparable_requirement_violation(__i);
|
williamr@4
|
582 |
// Valid Expressions
|
williamr@4
|
583 |
_STL_ERROR::__dereference_operator_requirement_violation(__i);
|
williamr@4
|
584 |
}
|
williamr@4
|
585 |
};
|
williamr@4
|
586 |
|
williamr@4
|
587 |
template <class _TrivialIterator>
|
williamr@4
|
588 |
struct _Mutable_TrivialIterator_concept_specification {
|
williamr@4
|
589 |
static void
|
williamr@4
|
590 |
_Mutable_TrivialIterator_requirement_violation(_TrivialIterator __i) {
|
williamr@4
|
591 |
_TrivialIterator_concept_specification<_TrivialIterator>::
|
williamr@4
|
592 |
_TrivialIterator_requirement_violation(__i);
|
williamr@4
|
593 |
// Valid Expressions
|
williamr@4
|
594 |
_STL_ERROR::__dereference_operator_and_assignment_requirement_violation(__i);
|
williamr@4
|
595 |
}
|
williamr@4
|
596 |
};
|
williamr@4
|
597 |
|
williamr@4
|
598 |
/* InputIterator Requirements */
|
williamr@4
|
599 |
|
williamr@4
|
600 |
template <class _InputIterator>
|
williamr@4
|
601 |
struct _InputIterator_concept_specification {
|
williamr@4
|
602 |
static void
|
williamr@4
|
603 |
_InputIterator_requirement_violation(_InputIterator __i) {
|
williamr@4
|
604 |
// Refinement of TrivialIterator
|
williamr@4
|
605 |
_TrivialIterator_concept_specification<_InputIterator>::
|
williamr@4
|
606 |
_TrivialIterator_requirement_violation(__i);
|
williamr@4
|
607 |
// Associated Types
|
williamr@4
|
608 |
__difference_type_type_definition_requirement_violation<_InputIterator>();
|
williamr@4
|
609 |
__reference_type_definition_requirement_violation<_InputIterator>();
|
williamr@4
|
610 |
__pointer_type_definition_requirement_violation<_InputIterator>();
|
williamr@4
|
611 |
__iterator_category_type_definition_requirement_violation<_InputIterator>();
|
williamr@4
|
612 |
// Valid Expressions
|
williamr@4
|
613 |
_STL_ERROR::__preincrement_operator_requirement_violation(__i);
|
williamr@4
|
614 |
_STL_ERROR::__postincrement_operator_requirement_violation(__i);
|
williamr@4
|
615 |
}
|
williamr@4
|
616 |
};
|
williamr@4
|
617 |
|
williamr@4
|
618 |
/* OutputIterator Requirements */
|
williamr@4
|
619 |
|
williamr@4
|
620 |
template <class _OutputIterator>
|
williamr@4
|
621 |
struct _OutputIterator_concept_specification {
|
williamr@4
|
622 |
static void
|
williamr@4
|
623 |
_OutputIterator_requirement_violation(_OutputIterator __i) {
|
williamr@4
|
624 |
// Refinement of Assignable
|
williamr@4
|
625 |
_Assignable_concept_specification<_OutputIterator>::
|
williamr@4
|
626 |
_Assignable_requirement_violation(__i);
|
williamr@4
|
627 |
// Associated Types
|
williamr@4
|
628 |
__iterator_category_type_definition_requirement_violation<_OutputIterator>();
|
williamr@4
|
629 |
// Valid Expressions
|
williamr@4
|
630 |
_STL_ERROR::__dereference_operator_requirement_violation(__i);
|
williamr@4
|
631 |
_STL_ERROR::__preincrement_operator_requirement_violation(__i);
|
williamr@4
|
632 |
_STL_ERROR::__postincrement_operator_requirement_violation(__i);
|
williamr@4
|
633 |
_STL_ERROR::
|
williamr@4
|
634 |
__postincrement_operator_and_assignment_requirement_violation(__i, *__i);
|
williamr@4
|
635 |
}
|
williamr@4
|
636 |
};
|
williamr@4
|
637 |
|
williamr@4
|
638 |
/* ForwardIterator Requirements */
|
williamr@4
|
639 |
|
williamr@4
|
640 |
template <class _ForwardIterator>
|
williamr@4
|
641 |
struct _ForwardIterator_concept_specification {
|
williamr@4
|
642 |
static void
|
williamr@4
|
643 |
_ForwardIterator_requirement_violation(_ForwardIterator __i) {
|
williamr@4
|
644 |
// Refinement of InputIterator
|
williamr@4
|
645 |
_InputIterator_concept_specification<_ForwardIterator>::
|
williamr@4
|
646 |
_InputIterator_requirement_violation(__i);
|
williamr@4
|
647 |
}
|
williamr@4
|
648 |
};
|
williamr@4
|
649 |
|
williamr@4
|
650 |
template <class _ForwardIterator>
|
williamr@4
|
651 |
struct _Mutable_ForwardIterator_concept_specification {
|
williamr@4
|
652 |
static void
|
williamr@4
|
653 |
_Mutable_ForwardIterator_requirement_violation(_ForwardIterator __i) {
|
williamr@4
|
654 |
_ForwardIterator_concept_specification<_ForwardIterator>::
|
williamr@4
|
655 |
_ForwardIterator_requirement_violation(__i);
|
williamr@4
|
656 |
// Refinement of OutputIterator
|
williamr@4
|
657 |
_OutputIterator_concept_specification<_ForwardIterator>::
|
williamr@4
|
658 |
_OutputIterator_requirement_violation(__i);
|
williamr@4
|
659 |
}
|
williamr@4
|
660 |
};
|
williamr@4
|
661 |
|
williamr@4
|
662 |
/* BidirectionalIterator Requirements */
|
williamr@4
|
663 |
|
williamr@4
|
664 |
template <class _BidirectionalIterator>
|
williamr@4
|
665 |
struct _BidirectionalIterator_concept_specification {
|
williamr@4
|
666 |
static void
|
williamr@4
|
667 |
_BidirectionalIterator_requirement_violation(_BidirectionalIterator __i) {
|
williamr@4
|
668 |
// Refinement of ForwardIterator
|
williamr@4
|
669 |
_ForwardIterator_concept_specification<_BidirectionalIterator>::
|
williamr@4
|
670 |
_ForwardIterator_requirement_violation(__i);
|
williamr@4
|
671 |
// Valid Expressions
|
williamr@4
|
672 |
_STL_ERROR::__predecrement_operator_requirement_violation(__i);
|
williamr@4
|
673 |
_STL_ERROR::__postdecrement_operator_requirement_violation(__i);
|
williamr@4
|
674 |
}
|
williamr@4
|
675 |
};
|
williamr@4
|
676 |
|
williamr@4
|
677 |
template <class _BidirectionalIterator>
|
williamr@4
|
678 |
struct _Mutable_BidirectionalIterator_concept_specification {
|
williamr@4
|
679 |
static void
|
williamr@4
|
680 |
_Mutable_BidirectionalIterator_requirement_violation(
|
williamr@4
|
681 |
_BidirectionalIterator __i)
|
williamr@4
|
682 |
{
|
williamr@4
|
683 |
_BidirectionalIterator_concept_specification<_BidirectionalIterator>::
|
williamr@4
|
684 |
_BidirectionalIterator_requirement_violation(__i);
|
williamr@4
|
685 |
// Refinement of mutable_ForwardIterator
|
williamr@4
|
686 |
_Mutable_ForwardIterator_concept_specification<_BidirectionalIterator>::
|
williamr@4
|
687 |
_Mutable_ForwardIterator_requirement_violation(__i);
|
williamr@4
|
688 |
typedef typename
|
williamr@4
|
689 |
__value_type_type_definition_requirement_violation<
|
williamr@4
|
690 |
_BidirectionalIterator>::value_type __T;
|
williamr@4
|
691 |
typename _Mutable_trait<__T>::_Type* __tmp_ptr = 0;
|
williamr@4
|
692 |
// Valid Expressions
|
williamr@4
|
693 |
_STL_ERROR::
|
williamr@4
|
694 |
__postincrement_operator_and_assignment_requirement_violation(__i,
|
williamr@4
|
695 |
*__tmp_ptr);
|
williamr@4
|
696 |
}
|
williamr@4
|
697 |
};
|
williamr@4
|
698 |
|
williamr@4
|
699 |
/* RandomAccessIterator Requirements */
|
williamr@4
|
700 |
|
williamr@4
|
701 |
template <class _RandAccIter>
|
williamr@4
|
702 |
struct _RandomAccessIterator_concept_specification {
|
williamr@4
|
703 |
static void
|
williamr@4
|
704 |
_RandomAccessIterator_requirement_violation(_RandAccIter __i) {
|
williamr@4
|
705 |
// Refinement of BidirectionalIterator
|
williamr@4
|
706 |
_BidirectionalIterator_concept_specification<_RandAccIter>::
|
williamr@4
|
707 |
_BidirectionalIterator_requirement_violation(__i);
|
williamr@4
|
708 |
// Refinement of LessThanComparable
|
williamr@4
|
709 |
_LessThanComparable_concept_specification<_RandAccIter>::
|
williamr@4
|
710 |
_LessThanComparable_requirement_violation(__i);
|
williamr@4
|
711 |
typedef typename
|
williamr@4
|
712 |
__value_type_type_definition_requirement_violation<_RandAccIter>
|
williamr@4
|
713 |
::value_type
|
williamr@4
|
714 |
value_type;
|
williamr@4
|
715 |
typedef typename
|
williamr@4
|
716 |
__difference_type_type_definition_requirement_violation<_RandAccIter>
|
williamr@4
|
717 |
::difference_type
|
williamr@4
|
718 |
_Dist;
|
williamr@4
|
719 |
typedef typename _Mutable_trait<_Dist>::_Type _MutDist;
|
williamr@4
|
720 |
|
williamr@4
|
721 |
// Valid Expressions
|
williamr@4
|
722 |
_STL_ERROR::__iterator_addition_assignment_requirement_violation(__i,
|
williamr@4
|
723 |
_MutDist());
|
williamr@4
|
724 |
_STL_ERROR::__iterator_addition_requirement_violation(__i,
|
williamr@4
|
725 |
_MutDist());
|
williamr@4
|
726 |
_STL_ERROR::
|
williamr@4
|
727 |
__iterator_subtraction_assignment_requirement_violation(__i,
|
williamr@4
|
728 |
_MutDist());
|
williamr@4
|
729 |
_STL_ERROR::__iterator_subtraction_requirement_violation(__i,
|
williamr@4
|
730 |
_MutDist());
|
williamr@4
|
731 |
_STL_ERROR::__difference_operator_requirement_violation(__i, __i,
|
williamr@4
|
732 |
_MutDist());
|
williamr@4
|
733 |
typename _Mutable_trait<value_type>::_Type* __dummy_ptr = 0;
|
williamr@4
|
734 |
_STL_ERROR::__element_access_operator_requirement_violation(__i,
|
williamr@4
|
735 |
__dummy_ptr,
|
williamr@4
|
736 |
_MutDist());
|
williamr@4
|
737 |
}
|
williamr@4
|
738 |
};
|
williamr@4
|
739 |
|
williamr@4
|
740 |
template <class _RandAccIter>
|
williamr@4
|
741 |
struct _Mutable_RandomAccessIterator_concept_specification {
|
williamr@4
|
742 |
static void
|
williamr@4
|
743 |
_Mutable_RandomAccessIterator_requirement_violation(_RandAccIter __i)
|
williamr@4
|
744 |
{
|
williamr@4
|
745 |
_RandomAccessIterator_concept_specification<_RandAccIter>::
|
williamr@4
|
746 |
_RandomAccessIterator_requirement_violation(__i);
|
williamr@4
|
747 |
// Refinement of mutable_BidirectionalIterator
|
williamr@4
|
748 |
_Mutable_BidirectionalIterator_concept_specification<_RandAccIter>::
|
williamr@4
|
749 |
_Mutable_BidirectionalIterator_requirement_violation(__i);
|
williamr@4
|
750 |
typedef typename
|
williamr@4
|
751 |
__value_type_type_definition_requirement_violation<_RandAccIter>
|
williamr@4
|
752 |
::value_type
|
williamr@4
|
753 |
value_type;
|
williamr@4
|
754 |
typedef typename
|
williamr@4
|
755 |
__difference_type_type_definition_requirement_violation<_RandAccIter>
|
williamr@4
|
756 |
::difference_type
|
williamr@4
|
757 |
_Dist;
|
williamr@4
|
758 |
|
williamr@4
|
759 |
typename _Mutable_trait<value_type>::_Type* __tmp_ptr = 0;
|
williamr@4
|
760 |
// Valid Expressions
|
williamr@4
|
761 |
_STL_ERROR::__element_assignment_operator_requirement_violation(__i,
|
williamr@4
|
762 |
__tmp_ptr, _Dist());
|
williamr@4
|
763 |
}
|
williamr@4
|
764 |
};
|
williamr@4
|
765 |
|
williamr@4
|
766 |
#define _STLP_TYPEDEF_REQUIREMENT(__REQUIREMENT) \
|
williamr@4
|
767 |
template <class Type> \
|
williamr@4
|
768 |
struct __##__REQUIREMENT##__typedef_requirement_violation { \
|
williamr@4
|
769 |
typedef typename Type::__REQUIREMENT __REQUIREMENT; \
|
williamr@4
|
770 |
};
|
williamr@4
|
771 |
|
williamr@4
|
772 |
_STLP_TYPEDEF_REQUIREMENT(value_type);
|
williamr@4
|
773 |
_STLP_TYPEDEF_REQUIREMENT(difference_type);
|
williamr@4
|
774 |
_STLP_TYPEDEF_REQUIREMENT(size_type);
|
williamr@4
|
775 |
_STLP_TYPEDEF_REQUIREMENT(reference);
|
williamr@4
|
776 |
_STLP_TYPEDEF_REQUIREMENT(const_reference);
|
williamr@4
|
777 |
_STLP_TYPEDEF_REQUIREMENT(pointer);
|
williamr@4
|
778 |
_STLP_TYPEDEF_REQUIREMENT(const_pointer);
|
williamr@4
|
779 |
|
williamr@4
|
780 |
|
williamr@4
|
781 |
template <class _Alloc>
|
williamr@4
|
782 |
struct _Allocator_concept_specification {
|
williamr@4
|
783 |
static void
|
williamr@4
|
784 |
_Allocator_requirement_violation(_Alloc __a) {
|
williamr@4
|
785 |
// Refinement of DefaultConstructible
|
williamr@4
|
786 |
_DefaultConstructible_concept_specification<_Alloc>::
|
williamr@4
|
787 |
_DefaultConstructible_requirement_violation(__a);
|
williamr@4
|
788 |
// Refinement of EqualityComparable
|
williamr@4
|
789 |
_EqualityComparable_concept_specification<_Alloc>::
|
williamr@4
|
790 |
_EqualityComparable_requirement_violation(__a);
|
williamr@4
|
791 |
// Associated Types
|
williamr@4
|
792 |
__value_type__typedef_requirement_violation<_Alloc>();
|
williamr@4
|
793 |
__difference_type__typedef_requirement_violation<_Alloc>();
|
williamr@4
|
794 |
__size_type__typedef_requirement_violation<_Alloc>();
|
williamr@4
|
795 |
__reference__typedef_requirement_violation<_Alloc>();
|
williamr@4
|
796 |
__const_reference__typedef_requirement_violation<_Alloc>();
|
williamr@4
|
797 |
__pointer__typedef_requirement_violation<_Alloc>();
|
williamr@4
|
798 |
__const_pointer__typedef_requirement_violation<_Alloc>();
|
williamr@4
|
799 |
typedef typename _Alloc::value_type _Type;
|
williamr@4
|
800 |
_STLP_REQUIRES_SAME_TYPE(typename _Alloc::rebind<_Type>::other, _Alloc);
|
williamr@4
|
801 |
}
|
williamr@4
|
802 |
};
|
williamr@4
|
803 |
|
williamr@4
|
804 |
#endif /* _STLP_USE_CONCEPT_CHECKS */
|
williamr@4
|
805 |
|
williamr@4
|
806 |
#endif /* __CONCEPT_CHECKS_H */
|
williamr@4
|
807 |
|
williamr@4
|
808 |
// Local Variables:
|
williamr@4
|
809 |
// mode:C++
|
williamr@4
|
810 |
// End:
|