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