Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4680 | right-hear | 1 | /* |
2 | * Copyright (c) 1999 |
||
3 | * Silicon Graphics Computer Systems, Inc. |
||
4 | * |
||
5 | * Permission to use, copy, modify, distribute and sell this software |
||
6 | * and its documentation for any purpose is hereby granted without fee, |
||
7 | * provided that the above copyright notice appear in all copies and |
||
8 | * that both that copyright notice and this permission notice appear |
||
9 | * in supporting documentation. Silicon Graphics makes no |
||
10 | * representations about the suitability of this software for any |
||
11 | * purpose. It is provided "as is" without express or implied warranty. |
||
12 | */ |
||
13 | |||
14 | #ifndef __STL_CONTAINER_CONCEPTS_H |
||
15 | #define __STL_CONTAINER_CONCEPTS_H |
||
16 | |||
17 | |||
18 | #include |
||
19 | |||
20 | #ifdef __STL_USE_CONCEPT_CHECKS |
||
21 | |||
22 | |||
23 | // This file covers the following concepts: |
||
24 | // _Container |
||
25 | // _ForwardContainer |
||
26 | // _ReversibleContainer |
||
27 | // _const_ReversibleContainer |
||
28 | // _RandomAccessContainer |
||
29 | // |
||
30 | |||
31 | struct _ERROR_IN_STL_CONTAINER { |
||
32 | |||
33 | /* Container expresssions */ |
||
34 | |||
35 | template |
||
36 | static void |
||
37 | __begin_iterator_accessor_requirement_violation(_Container __c) { |
||
38 | __c.begin(); |
||
39 | } |
||
40 | template |
||
41 | static void |
||
42 | __const_begin_iterator_accessor_requirement_violation(const _Container& __c) { |
||
43 | __c.begin(); |
||
44 | } |
||
45 | template |
||
46 | static void |
||
47 | __end_iterator_accessor_requirement_violation(_Container __c) { |
||
48 | __c.end(); |
||
49 | } |
||
50 | template |
||
51 | static void |
||
52 | __const_end_iterator_accessor_requirement_violation(const _Container& __c) { |
||
53 | __c.end(); |
||
54 | } |
||
55 | |||
56 | template |
||
57 | static void |
||
58 | __rbegin_iterator_accessor_requirement_violation(_Container __c) { |
||
59 | __c.rbegin(); |
||
60 | } |
||
61 | template |
||
62 | static void |
||
63 | __const_rbegin_iterator_accessor_requirement_violation(const _Container& __c) { |
||
64 | __c.rbegin(); |
||
65 | } |
||
66 | template |
||
67 | static void |
||
68 | __rend_iterator_accessor_requirement_violation(_Container __c) { |
||
69 | __c.rend(); |
||
70 | } |
||
71 | template |
||
72 | static void |
||
73 | __const_rend_iterator_accessor_requirement_violation(const _Container& __c) { |
||
74 | __c.rend(); |
||
75 | } |
||
76 | template |
||
77 | static void |
||
78 | __size_function_must_be_const(const _Container& __c) { |
||
79 | __c.size(); |
||
80 | } |
||
81 | template |
||
82 | static void |
||
83 | __size_function_requirement_violation(_Container& __c) { |
||
84 | __c.size(); |
||
85 | __size_function_must_be_const(__c); |
||
86 | } |
||
87 | template |
||
88 | static void |
||
89 | __max_size_function_must_be_const(const _Container& __c) { |
||
90 | __c.max_size(); |
||
91 | } |
||
92 | template |
||
93 | static void |
||
94 | __max_size_function_requirement_violation(_Container& __c) { |
||
95 | __c.max_size(); |
||
96 | __max_size_function_must_be_const(__c); |
||
97 | } |
||
98 | template |
||
99 | static void |
||
100 | __empty_function_must_be_const(const _Container& __c) { |
||
101 | __c.empty(); |
||
102 | } |
||
103 | template |
||
104 | static void |
||
105 | __empty_function_requirement_violation(_Container& __c) { |
||
106 | __c.empty(); |
||
107 | __empty_function_must_be_const(__c); |
||
108 | } |
||
109 | template |
||
110 | static void |
||
111 | __swap_function_requirement_violation(_Container& __c) { |
||
112 | __c.swap(__c); |
||
113 | } |
||
114 | |||
115 | }; |
||
116 | |||
117 | |||
118 | __STL_TYPEDEF_REQUIREMENT(iterator); |
||
119 | __STL_TYPEDEF_REQUIREMENT(const_iterator); |
||
120 | |||
121 | /* Containers */ |
||
122 | |||
123 | template |
||
124 | struct _Container_concept_specification { |
||
125 | static void |
||
126 | _Container_requirement_violation(_Container __c) { |
||
127 | // Refinement of Assignable |
||
128 | _Assignable_concept_specification<_Container>::_Assignable_requirement_violation(__c); |
||
129 | // Associated Types |
||
130 | __value_type__typedef_requirement_violation<_Container>(); |
||
131 | __difference_type__typedef_requirement_violation<_Container>(); |
||
132 | __size_type__typedef_requirement_violation<_Container>(); |
||
133 | __reference__typedef_requirement_violation<_Container>(); |
||
134 | __const_reference__typedef_requirement_violation<_Container>(); |
||
135 | __pointer__typedef_requirement_violation<_Container>(); |
||
136 | __const_pointer__typedef_requirement_violation<_Container>(); |
||
137 | __iterator__typedef_requirement_violation<_Container>(); |
||
138 | __const_iterator__typedef_requirement_violation<_Container>(); |
||
139 | // Valid Expressions |
||
140 | _ERROR_IN_STL_CONTAINER::__const_begin_iterator_accessor_requirement_violation(__c); |
||
141 | _ERROR_IN_STL_CONTAINER::__const_end_iterator_accessor_requirement_violation(__c); |
||
142 | _ERROR_IN_STL_CONTAINER::__begin_iterator_accessor_requirement_violation(__c); |
||
143 | _ERROR_IN_STL_CONTAINER::__end_iterator_accessor_requirement_violation(__c); |
||
144 | _ERROR_IN_STL_CONTAINER::__size_function_requirement_violation(__c); |
||
145 | _ERROR_IN_STL_CONTAINER::__max_size_function_requirement_violation(__c); |
||
146 | _ERROR_IN_STL_CONTAINER::__empty_function_requirement_violation(__c); |
||
147 | _ERROR_IN_STL_CONTAINER::__swap_function_requirement_violation(__c); |
||
148 | // Requirements on Iterators |
||
149 | typedef typename _Container::iterator iter; |
||
150 | typedef typename _Container::const_iterator const_iter; |
||
151 | _InputIterator_concept_specification |
||
152 | _InputIterator_concept_specification |
||
153 | } |
||
154 | }; |
||
155 | |||
156 | template |
||
157 | struct _ForwardContainer_concept_specification { |
||
158 | static void |
||
159 | _ForwardContainer_requirement_violation(_ForwardContainer __c) { |
||
160 | // Refinement of Container |
||
161 | _Container_concept_specification<_ForwardContainer>::_Container_requirement_violation(__c); |
||
162 | // Requirements on Iterators |
||
163 | typedef typename _ForwardContainer::iterator iter; |
||
164 | typedef typename _ForwardContainer::const_iterator const_iter; |
||
165 | _ForwardIterator_concept_specification |
||
166 | _Mutable_ForwardIterator_concept_specification |
||
167 | } |
||
168 | }; |
||
169 | |||
170 | |||
171 | __STL_TYPEDEF_REQUIREMENT(reverse_iterator); |
||
172 | __STL_TYPEDEF_REQUIREMENT(const_reverse_iterator); |
||
173 | |||
174 | template |
||
175 | struct _ReversibleContainer_concept_specification { |
||
176 | static void |
||
177 | _ReversibleContainer_requirement_violation(_ReversibleContainer __c) { |
||
178 | // Refinement of ForwardContainer |
||
179 | _ForwardContainer_concept_specification<_ReversibleContainer>::_ForwardContainer_requirement_violation(__c); |
||
180 | // Associated types |
||
181 | __reverse_iterator__typedef_requirement_violation<_ReversibleContainer>(); |
||
182 | __const_reverse_iterator__typedef_requirement_violation<_ReversibleContainer>(); |
||
183 | // Valid Expressions |
||
184 | _ERROR_IN_STL_CONTAINER::__const_rbegin_iterator_accessor_requirement_violation(__c); |
||
185 | _ERROR_IN_STL_CONTAINER::__const_rend_iterator_accessor_requirement_violation(__c); |
||
186 | _ERROR_IN_STL_CONTAINER::__rbegin_iterator_accessor_requirement_violation(__c); |
||
187 | _ERROR_IN_STL_CONTAINER::__rend_iterator_accessor_requirement_violation(__c); |
||
188 | // Requirements on Iterators |
||
189 | typedef typename _ReversibleContainer::iterator iter; |
||
190 | typedef typename _ReversibleContainer::const_iterator const_iter; |
||
191 | _BidirectionalIterator_concept_specification |
||
192 | _Mutable_BidirectionalIterator_concept_specification |
||
193 | } |
||
194 | }; |
||
195 | |||
196 | template |
||
197 | struct _const_ReversibleContainer_concept_specification { |
||
198 | static void |
||
199 | _const_ReversibleContainer_requirement_violation(_ReversibleContainer __c) { |
||
200 | // Refinement of Container (JGS, not ForwardContainer) |
||
201 | _Container_concept_specification<_ReversibleContainer>::_Container_requirement_violation(__c); |
||
202 | // Associated types |
||
203 | __reverse_iterator__typedef_requirement_violation<_ReversibleContainer>(); |
||
204 | __const_reverse_iterator__typedef_requirement_violation<_ReversibleContainer>(); |
||
205 | // Valid Expressions |
||
206 | _ERROR_IN_STL_CONTAINER::__const_rbegin_iterator_accessor_requirement_violation(__c); |
||
207 | _ERROR_IN_STL_CONTAINER::__const_rend_iterator_accessor_requirement_violation(__c); |
||
208 | _ERROR_IN_STL_CONTAINER::__rbegin_iterator_accessor_requirement_violation(__c); |
||
209 | _ERROR_IN_STL_CONTAINER::__rend_iterator_accessor_requirement_violation(__c); |
||
210 | // Requirements on Iterators |
||
211 | typedef typename _ReversibleContainer::iterator iter; |
||
212 | typedef typename _ReversibleContainer::const_iterator const_iter; |
||
213 | |||
214 | _BidirectionalIterator_concept_specification |
||
215 | } |
||
216 | }; |
||
217 | |||
218 | |||
219 | template |
||
220 | struct _RandomAccessContainer_concept_specification { |
||
221 | static void |
||
222 | _RandomAccessContainer_requirement_violation(_RandomAccessContainer __c) { |
||
223 | // Refinement of ReversibleContainer |
||
224 | _ReversibleContainer_concept_specification<_RandomAccessContainer>::_ReversibleContainer_requirement_violation(__c); |
||
225 | // Valid Expressions |
||
226 | typedef typename _RandomAccessContainer::value_type __T; |
||
227 | typedef typename _RandomAccessContainer::difference_type _Dist; |
||
228 | typedef typename _Mutable_trait<__T>::_Type Type; |
||
229 | typedef Type* _TypePtr; |
||
230 | typedef typename _Mutable_trait<_Dist>::_Type Dist; |
||
231 | _STL_ERROR::__element_access_operator_requirement_violation(__c, |
||
232 | _TypePtr(), |
||
233 | Dist()); |
||
234 | // Requirements on Iterators |
||
235 | typedef typename _RandomAccessContainer::iterator iter; |
||
236 | typedef typename _RandomAccessContainer::const_iterator const_iter; |
||
237 | _RandomAccessIterator_concept_specification |
||
238 | _Mutable_RandomAccessIterator_concept_specification |
||
239 | } |
||
240 | }; |
||
241 | |||
242 | #endif /* if __STL_USE_CONCEPT_CHECKS */ |
||
243 | |||
244 | #endif /* __STL_CONTAINER_CONCEPTS_H */ |