concept_checks.h

00001 /*
00002  * Copyright (c) 1999
00003  * Silicon Graphics Computer Systems, Inc.
00004  *
00005  * Permission to use, copy, modify, distribute and sell this software
00006  * and its documentation for any purpose is hereby granted without fee,
00007  * provided that the above copyright notice appear in all copies and
00008  * that both that copyright notice and this permission notice appear
00009  * in supporting documentation.  Silicon Graphics makes no
00010  * representations about the suitability of this software for any
00011  * purpose.  It is provided "as is" without express or implied warranty.
00012  */
00013 
00014 #ifndef __CONCEPT_CHECKS_H
00015 #define __CONCEPT_CHECKS_H
00016 
00017 /*
00018   Use these macro like assertions, but they assert properties
00019   on types (usually template arguments). In technical terms they
00020   verify whether a type "models" a "concept".
00021 
00022   This set of requirements and the terminology used here is derived
00023   from the book "Generic Programming and the STL" by Matt Austern
00024   (Addison Wesley). For further information please consult that
00025   book. The requirements also are intended to match the ANSI/ISO C++
00026   standard.
00027 
00028   This file covers the basic concepts and the iterator concepts.
00029   There are several other files that provide the requirements
00030   for the STL containers:
00031     container_concepts.h
00032     sequence_concepts.h
00033     assoc_container_concepts.h
00034 
00035   Jeremy Siek, 1999
00036 
00037   TO DO:
00038     - some issues with regards to concept classification and mutability
00039       including AssociativeContianer -> ForwardContainer
00040       and SortedAssociativeContainer -> ReversibleContainer
00041     - HashedAssociativeContainer
00042     - Allocator
00043     - Function Object Concepts
00044 
00045   */
00046 
00047 #ifndef _STLP_USE_CONCEPT_CHECKS
00048 
00049 // Some compilers lack the features that are necessary for concept checks.
00050 // On those compilers we define the concept check macros to do nothing.
00051 #define _STLP_REQUIRES(__type_var, __concept) do {} while(0)
00052 #define _STLP_CLASS_REQUIRES(__type_var, __concept) \
00053   static int  __##__type_var##_##__concept
00054 #define _STLP_CONVERTIBLE(__type_x, __type_y) do {} while(0)
00055 #define _STLP_REQUIRES_SAME_TYPE(__type_x, __type_y) do {} while(0)
00056 #define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \
00057   static int  __##__type_x##__type_y##_require_same_type
00058 #define _STLP_GENERATOR_CHECK(__func, __ret) do {} while(0)
00059 #define _STLP_CLASS_GENERATOR_CHECK(__func, __ret) \
00060   static int  __##__func##__ret##_generator_check
00061 #define _STLP_UNARY_FUNCTION_CHECK(__func, __ret, __arg) do {} while(0)
00062 #define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \
00063   static int  __##__func##__ret##__arg##_unary_function_check
00064 #define _STLP_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
00065   do {} while(0)
00066 #define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
00067   static int  __##__func##__ret##__first##__second##_binary_function_check
00068 #define _STLP_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
00069   do {} while(0)
00070 #define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
00071   static int __##__opname##__ret##__first##__second##_require_binary_op
00072 
00073 #else /* _STLP_USE_CONCEPT_CHECKS */
00074 
00075 // This macro tests whether the template argument "__type_var"
00076 // satisfies the requirements of "__concept".  Here is a list of concepts
00077 // that we know how to check:
00078 //       _Allocator
00079 //       _Assignable
00080 //       _DefaultConstructible
00081 //       _EqualityComparable
00082 //       _LessThanComparable
00083 //       _TrivialIterator
00084 //       _InputIterator
00085 //       _OutputIterator
00086 //       _ForwardIterator
00087 //       _BidirectionalIterator
00088 //       _RandomAccessIterator
00089 //       _Mutable_TrivialIterator
00090 //       _Mutable_ForwardIterator
00091 //       _Mutable_BidirectionalIterator
00092 //       _Mutable_RandomAccessIterator
00093 
00094 #define _STLP_REQUIRES(__type_var, __concept) \
00095 do { \
00096   void (*__x)( __type_var ) = __concept##_concept_specification< __type_var >\
00097     ::##__concept##_requirement_violation; __x = __x; } while (0)
00098 
00099 // Use this to check whether type X is convertible to type Y
00100 #define _STLP_CONVERTIBLE(__type_x, __type_y) \
00101 do { \
00102   void (*__x)( __type_x , __type_y ) = _STL_CONVERT_ERROR< __type_x , \
00103   __type_y >::__type_X_is_not_convertible_to_type_Y; \
00104   __x = __x; } while (0)
00105 
00106 // Use this to test whether two template arguments are the same type
00107 #define _STLP_REQUIRES_SAME_TYPE(__type_x, __type_y) \
00108 do { \
00109   void (*__x)( __type_x , __type_y ) = _STL_SAME_TYPE_ERROR< __type_x, \
00110     __type_y  >::__type_X_not_same_as_type_Y; \
00111   __x = __x; } while (0)
00112 
00113 
00114 // function object checks
00115 #define _STLP_GENERATOR_CHECK(__func, __ret) \
00116 do { \
00117   __ret (*__x)( __func&) = \
00118      _STL_GENERATOR_ERROR< \
00119   __func, __ret>::__generator_requirement_violation; \
00120   __x = __x; } while (0)
00121 
00122 
00123 #define _STLP_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \
00124 do { \
00125   __ret (*__x)( __func&, const __arg& ) = \
00126      _STL_UNARY_FUNCTION_ERROR< \
00127   __func, __ret, __arg>::__unary_function_requirement_violation; \
00128   __x = __x; } while (0)
00129 
00130 
00131 #define _STLP_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
00132 do { \
00133   __ret (*__x)( __func&, const __first&, const __second& ) = \
00134      _STL_BINARY_FUNCTION_ERROR< \
00135   __func, __ret, __first, __second>::__binary_function_requirement_violation; \
00136   __x = __x; } while (0)
00137 
00138 
00139 #define _STLP_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
00140     do { \
00141   __ret (*__x)( __first&, __second& ) = _STL_BINARY##__opname##_ERROR< \
00142     __ret, __first, __second>::__binary_operator_requirement_violation; \
00143   __ret (*__y)( const __first&, const __second& ) = \
00144     _STL_BINARY##__opname##_ERROR< __ret, __first, __second>:: \
00145       __const_binary_operator_requirement_violation; \
00146   __y = __y; __x = __x; } while (0)
00147 
00148 
00149 #ifdef _STLP_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE
00150 
00151 #define _STLP_CLASS_REQUIRES(__type_var, __concept)
00152 #define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y)
00153 #define _STLP_CLASS_GENERATOR_CHECK(__func, __ret)
00154 #define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg)
00155 #define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second)
00156 #define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second)
00157 
00158 #else
00159 
00160 // Use this macro inside of template classes, where you would
00161 // like to place requirements on the template arguments to the class
00162 // Warning: do not pass pointers and such (e.g. T*) in as the __type_var,
00163 // since the type_var is used to construct identifiers. Instead typedef
00164 // the pointer type, then use the typedef name for the __type_var.
00165 #define _STLP_CLASS_REQUIRES(__type_var, __concept) \
00166   typedef void (* __func##__type_var##__concept)( __type_var ); \
00167   template <__func##__type_var##__concept _Tp1> \
00168   struct __dummy_struct_##__type_var##__concept { }; \
00169   static __dummy_struct_##__type_var##__concept< \
00170     __concept##_concept_specification< \
00171       __type_var>::__concept##_requirement_violation>  \
00172   __dummy_ptr_##__type_var##__concept
00173 
00174 
00175 #define _STLP_CLASS_REQUIRES_SAME_TYPE(__type_x, __type_y) \
00176   typedef void (* __func_##__type_x##__type_y##same_type)( __type_x, \
00177                                                             __type_y ); \
00178   template < __func_##__type_x##__type_y##same_type _Tp1> \
00179   struct __dummy_struct_##__type_x##__type_y##_same_type { }; \
00180   static __dummy_struct_##__type_x##__type_y##_same_type< \
00181     _STL_SAME_TYPE_ERROR<__type_x, __type_y>::__type_X_not_same_as_type_Y>  \
00182   __dummy_ptr_##__type_x##__type_y##_same_type
00183 
00184 
00185 #define _STLP_CLASS_GENERATOR_CHECK(__func, __ret) \
00186   typedef __ret (* __f_##__func##__ret##_generator)( __func& ); \
00187   template <__f_##__func##__ret##_generator _Tp1> \
00188   struct __dummy_struct_##__func##__ret##_generator { }; \
00189   static __dummy_struct_##__func##__ret##_generator< \
00190     _STL_GENERATOR_ERROR< \
00191       __func, __ret>::__generator_requirement_violation>  \
00192   __dummy_ptr_##__func##__ret##_generator
00193 
00194 
00195 #define _STLP_CLASS_UNARY_FUNCTION_CHECK(__func, __ret, __arg) \
00196   typedef __ret (* __f_##__func##__ret##__arg##_unary_check)( __func&, \
00197                                                          const __arg& ); \
00198   template <__f_##__func##__ret##__arg##_unary_check _Tp1> \
00199   struct __dummy_struct_##__func##__ret##__arg##_unary_check { }; \
00200   static __dummy_struct_##__func##__ret##__arg##_unary_check< \
00201     _STL_UNARY_FUNCTION_ERROR< \
00202       __func, __ret, __arg>::__unary_function_requirement_violation>  \
00203   __dummy_ptr_##__func##__ret##__arg##_unary_check
00204 
00205 
00206 #define _STLP_CLASS_BINARY_FUNCTION_CHECK(__func, __ret, __first, __second) \
00207   typedef __ret (* __f_##__func##__ret##__first##__second##_binary_check)( __func&, const __first&,\
00208                                                     const __second& ); \
00209   template <__f_##__func##__ret##__first##__second##_binary_check _Tp1> \
00210   struct __dummy_struct_##__func##__ret##__first##__second##_binary_check { }; \
00211   static __dummy_struct_##__func##__ret##__first##__second##_binary_check< \
00212     _STL_BINARY_FUNCTION_ERROR<__func, __ret, __first, __second>:: \
00213   __binary_function_requirement_violation>  \
00214   __dummy_ptr_##__func##__ret##__first##__second##_binary_check
00215 
00216 
00217 #define _STLP_CLASS_REQUIRES_BINARY_OP(__opname, __ret, __first, __second) \
00218   typedef __ret (* __f_##__func##__ret##__first##__second##_binary_op)(const __first&, \
00219                                                     const __second& ); \
00220   template <__f_##__func##__ret##__first##__second##_binary_op _Tp1> \
00221   struct __dummy_struct_##__func##__ret##__first##__second##_binary_op { }; \
00222   static __dummy_struct_##__func##__ret##__first##__second##_binary_op< \
00223     _STL_BINARY##__opname##_ERROR<__ret, __first, __second>:: \
00224   __binary_operator_requirement_violation>  \
00225   __dummy_ptr_##__func##__ret##__first##__second##_binary_op
00226 
00227 #endif
00228 
00229 /* helper class for finding non-const version of a type. Need to have
00230    something to assign to etc. when testing constant iterators. */
00231 
00232 template <class _Tp>
00233 struct _Mutable_trait {
00234   typedef _Tp _Type;
00235 };
00236 template <class _Tp>
00237 struct _Mutable_trait<const _Tp> {
00238   typedef _Tp _Type;
00239 };
00240 
00241 
00242 /* helper function for avoiding compiler warnings about unused variables */
00243 template <class _Type>
00244 void __sink_unused_warning(_Type) { }
00245 
00246 template <class _TypeX, class _TypeY>
00247 struct _STL_CONVERT_ERROR {
00248   static void
00249   __type_X_is_not_convertible_to_type_Y(_TypeX __x, _TypeY) {
00250     _TypeY __y = __x;
00251     __sink_unused_warning(__y);
00252   }
00253 };
00254 
00255 
00256 template <class _Type> struct __check_equal { };
00257 
00258 template <class _TypeX, class _TypeY>
00259 struct _STL_SAME_TYPE_ERROR {
00260   static void
00261   __type_X_not_same_as_type_Y(_TypeX , _TypeY ) { 
00262     __check_equal<_TypeX> t1 = __check_equal<_TypeY>();
00263   }
00264 };
00265 
00266 
00267 // Some Functon Object Checks
00268 
00269 template <class _Func, class _Ret>
00270 struct _STL_GENERATOR_ERROR {
00271   static _Ret __generator_requirement_violation(_Func& __f) {
00272     return __f();
00273   }
00274 };
00275 
00276 template <class _Func>
00277 struct _STL_GENERATOR_ERROR<_Func, void> {
00278   static void __generator_requirement_violation(_Func& __f) {
00279     __f();
00280   }
00281 };
00282 
00283 
00284 template <class _Func, class _Ret, class _Arg>
00285 struct _STL_UNARY_FUNCTION_ERROR {
00286   static _Ret
00287   __unary_function_requirement_violation(_Func& __f,
00288                                           const _Arg& __arg) {
00289     return __f(__arg);
00290   }
00291 };
00292 
00293 template <class _Func, class _Arg>
00294 struct _STL_UNARY_FUNCTION_ERROR<_Func, void, _Arg> {
00295   static void
00296   __unary_function_requirement_violation(_Func& __f,
00297                                           const _Arg& __arg) {
00298     __f(__arg);
00299   }
00300 };
00301 
00302 template <class _Func, class _Ret, class _First, class _Second>
00303 struct _STL_BINARY_FUNCTION_ERROR {
00304   static _Ret
00305   __binary_function_requirement_violation(_Func& __f,
00306                                           const _First& __first, 
00307                                           const _Second& __second) {
00308     return __f(__first, __second);
00309   }
00310 };
00311 
00312 template <class _Func, class _First, class _Second>
00313 struct _STL_BINARY_FUNCTION_ERROR<_Func, void, _First, _Second> {
00314   static void
00315   __binary_function_requirement_violation(_Func& __f,
00316                                           const _First& __first, 
00317                                           const _Second& __second) {
00318     __f(__first, __second);
00319   }
00320 };
00321 
00322 
00323 #define _STLP_DEFINE_BINARY_OP_CHECK(_OP, _NAME) \
00324 template <class _Ret, class _First, class _Second> \
00325 struct _STL_BINARY##_NAME##_ERROR { \
00326   static _Ret \
00327   __const_binary_operator_requirement_violation(const _First& __first,  \
00328                                                 const _Second& __second) { \
00329     return __first _OP __second; \
00330   } \
00331   static _Ret \
00332   __binary_operator_requirement_violation(_First& __first,  \
00333                                           _Second& __second) { \
00334     return __first _OP __second; \
00335   } \
00336 }
00337 
00338 _STLP_DEFINE_BINARY_OP_CHECK(==, _OP_EQUAL);
00339 _STLP_DEFINE_BINARY_OP_CHECK(!=, _OP_NOT_EQUAL);
00340 _STLP_DEFINE_BINARY_OP_CHECK(<, _OP_LESS_THAN);
00341 _STLP_DEFINE_BINARY_OP_CHECK(<=, _OP_LESS_EQUAL);
00342 _STLP_DEFINE_BINARY_OP_CHECK(>, _OP_GREATER_THAN);
00343 _STLP_DEFINE_BINARY_OP_CHECK(>=, _OP_GREATER_EQUAL);
00344 _STLP_DEFINE_BINARY_OP_CHECK(+, _OP_PLUS);
00345 _STLP_DEFINE_BINARY_OP_CHECK(*, _OP_TIMES);
00346 _STLP_DEFINE_BINARY_OP_CHECK(/, _OP_DIVIDE);
00347 _STLP_DEFINE_BINARY_OP_CHECK(-, _OP_SUBTRACT);
00348 _STLP_DEFINE_BINARY_OP_CHECK(%, _OP_MOD);
00349 // ...
00350 
00351 // TODO, add unary operators (prefix and postfix)
00352 
00353 /*
00354   The presence of this class is just to trick EDG into displaying
00355   these error messages before any other errors. Without the
00356   classes, the errors in the functions get reported after
00357   other class errors deep inside the library. The name
00358   choice just makes for an eye catching error message :)
00359  */
00360 struct _STL_ERROR {
00361 
00362   template <class _Type>
00363   static _Type
00364   __default_constructor_requirement_violation(_Type) {
00365     return _Type();
00366   }
00367   template <class _Type>
00368   static _Type
00369   __assignment_operator_requirement_violation(_Type __a) {
00370     __a = __a;
00371     return __a;
00372   }
00373   template <class _Type>
00374   static _Type
00375   __copy_constructor_requirement_violation(_Type __a) {
00376     _Type __c(__a);
00377     return __c;
00378   }
00379   template <class _Type>
00380   static _Type
00381   __const_parameter_required_for_copy_constructor(_Type /* __a */, 
00382                                                   const _Type& __b) {
00383     _Type __c(__b);
00384     return __c;
00385   }
00386   template <class _Type>
00387   static _Type
00388   __const_parameter_required_for_assignment_operator(_Type __a, 
00389                                                      const _Type& __b) {
00390     __a = __b;
00391     return __a;
00392   }
00393   template <class _Type>
00394   static _Type
00395   __less_than_comparable_requirement_violation(_Type __a, _Type __b) {
00396     if (__a < __b || __a > __b || __a <= __b || __a >= __b) return __a;
00397     return __b;
00398   }
00399   template <class _Type>
00400   static _Type
00401   __equality_comparable_requirement_violation(_Type __a, _Type __b) {
00402     if (__a == __b || __a != __b) return __a;
00403     return __b;
00404   }
00405   template <class _Iterator>
00406   static void
00407   __dereference_operator_requirement_violation(_Iterator __i) {
00408     __sink_unused_warning(*__i);
00409   }
00410   template <class _Iterator>
00411   static void
00412   __dereference_operator_and_assignment_requirement_violation(_Iterator __i) {
00413     *__i = *__i;
00414   }
00415   template <class _Iterator>
00416   static void
00417   __preincrement_operator_requirement_violation(_Iterator __i) {
00418     ++__i;
00419   }
00420   template <class _Iterator>
00421   static void
00422   __postincrement_operator_requirement_violation(_Iterator __i) {
00423     __i++;
00424   }
00425   template <class _Iterator>
00426   static void
00427   __predecrement_operator_requirement_violation(_Iterator __i) {
00428     --__i;
00429   }
00430   template <class _Iterator>
00431   static void
00432   __postdecrement_operator_requirement_violation(_Iterator __i) {
00433     __i--;
00434   }
00435   template <class _Iterator, class _Type>
00436   static void
00437   __postincrement_operator_and_assignment_requirement_violation(_Iterator __i,
00438                                                                 _Type __t) {
00439     *__i++ = __t;
00440   }
00441   template <class _Iterator, class _Distance>
00442   static _Iterator
00443   __iterator_addition_assignment_requirement_violation(_Iterator __i, 
00444                                                        _Distance __n) {
00445     __i += __n;
00446     return __i;
00447   }
00448   template <class _Iterator, class _Distance>
00449   static _Iterator
00450   __iterator_addition_requirement_violation(_Iterator __i, _Distance __n) {
00451     __i = __i + __n;
00452     __i = __n + __i;
00453     return __i;
00454   }
00455   template <class _Iterator, class _Distance>
00456   static _Iterator
00457   __iterator_subtraction_assignment_requirement_violation(_Iterator __i,
00458                                                           _Distance __n) {
00459     __i -= __n;
00460     return __i;
00461   }
00462   template <class _Iterator, class _Distance>
00463   static _Iterator
00464   __iterator_subtraction_requirement_violation(_Iterator __i, _Distance __n) {
00465     __i = __i - __n;
00466     return __i;
00467   }
00468   template <class _Iterator, class _Distance>
00469   static _Distance
00470   __difference_operator_requirement_violation(_Iterator __i, _Iterator __j,
00471                                               _Distance __n) {
00472     __n = __i - __j;
00473     return __n;
00474   }
00475   template <class _Exp, class _Type, class _Distance>
00476   static _Type
00477   __element_access_operator_requirement_violation(_Exp __x, _Type*,
00478                                                   _Distance __n) {
00479     return __x[__n];
00480   }
00481   template <class _Exp, class _Type, class _Distance>
00482   static void
00483   __element_assignment_operator_requirement_violation(_Exp __x,
00484                                                       _Type* __t,
00485                                                       _Distance __n) {
00486     __x[__n] = *__t;
00487   }
00488 
00489 }; /* _STL_ERROR */
00490 
00491 /* Associated Type Requirements */
00492 
00493 _STLP_BEGIN_NAMESPACE
00494 template <class _Iterator> struct iterator_traits;
00495 _STLP_END_NAMESPACE
00496 
00497 template <class _Iter> 
00498 struct __value_type_type_definition_requirement_violation {
00499   typedef typename __STD::iterator_traits<_Iter>::value_type value_type;
00500 };
00501 
00502 template <class _Iter> 
00503 struct __difference_type_type_definition_requirement_violation {
00504   typedef typename __STD::iterator_traits<_Iter>::difference_type
00505           difference_type;
00506 };
00507 
00508 template <class _Iter> 
00509 struct __reference_type_definition_requirement_violation {
00510   typedef typename __STD::iterator_traits<_Iter>::reference reference;
00511 };
00512 
00513 template <class _Iter> 
00514 struct __pointer_type_definition_requirement_violation {
00515   typedef typename __STD::iterator_traits<_Iter>::pointer pointer;
00516 };
00517 
00518 template <class _Iter> 
00519 struct __iterator_category_type_definition_requirement_violation {
00520   typedef typename __STD::iterator_traits<_Iter>::iterator_category 
00521           iterator_category;
00522 };
00523 
00524 /* Assignable Requirements */
00525 
00526 
00527 template <class _Type>
00528 struct _Assignable_concept_specification {
00529   static void _Assignable_requirement_violation(_Type __a) {
00530     _STL_ERROR::__assignment_operator_requirement_violation(__a);
00531     _STL_ERROR::__copy_constructor_requirement_violation(__a);
00532     _STL_ERROR::__const_parameter_required_for_copy_constructor(__a,__a);
00533     _STL_ERROR::__const_parameter_required_for_assignment_operator(__a,__a);
00534   }
00535 };
00536 
00537 /* DefaultConstructible Requirements */
00538 
00539 
00540 template <class _Type>
00541 struct _DefaultConstructible_concept_specification {
00542   static void _DefaultConstructible_requirement_violation(_Type __a) {
00543     _STL_ERROR::__default_constructor_requirement_violation(__a);
00544   }
00545 };
00546 
00547 /* EqualityComparable Requirements */
00548 
00549 template <class _Type>
00550 struct _EqualityComparable_concept_specification {
00551   static void _EqualityComparable_requirement_violation(_Type __a) {
00552     _STL_ERROR::__equality_comparable_requirement_violation(__a, __a);
00553   }
00554 };
00555 
00556 /* LessThanComparable Requirements */
00557 template <class _Type>
00558 struct _LessThanComparable_concept_specification {
00559   static void _LessThanComparable_requirement_violation(_Type __a) {
00560     _STL_ERROR::__less_than_comparable_requirement_violation(__a, __a);
00561   }
00562 };
00563 
00564 /* TrivialIterator Requirements */
00565 
00566 template <class _TrivialIterator>
00567 struct _TrivialIterator_concept_specification {
00568 static void
00569 _TrivialIterator_requirement_violation(_TrivialIterator __i) {
00570   typedef typename
00571     __value_type_type_definition_requirement_violation<_TrivialIterator>::
00572     value_type __T;
00573   // Refinement of Assignable
00574   _Assignable_concept_specification<_TrivialIterator>::
00575     _Assignable_requirement_violation(__i);
00576   // Refinement of DefaultConstructible
00577   _DefaultConstructible_concept_specification<_TrivialIterator>::
00578     _DefaultConstructible_requirement_violation(__i);
00579   // Refinement of EqualityComparable
00580   _EqualityComparable_concept_specification<_TrivialIterator>::
00581     _EqualityComparable_requirement_violation(__i);
00582   // Valid Expressions
00583   _STL_ERROR::__dereference_operator_requirement_violation(__i);
00584 }
00585 };
00586 
00587 template <class _TrivialIterator>
00588 struct _Mutable_TrivialIterator_concept_specification {
00589 static void
00590 _Mutable_TrivialIterator_requirement_violation(_TrivialIterator __i) {
00591   _TrivialIterator_concept_specification<_TrivialIterator>::
00592     _TrivialIterator_requirement_violation(__i);
00593   // Valid Expressions
00594   _STL_ERROR::__dereference_operator_and_assignment_requirement_violation(__i);
00595 }
00596 };
00597 
00598 /* InputIterator Requirements */
00599 
00600 template <class _InputIterator>
00601 struct _InputIterator_concept_specification {
00602 static void
00603 _InputIterator_requirement_violation(_InputIterator __i) {
00604   // Refinement of TrivialIterator
00605   _TrivialIterator_concept_specification<_InputIterator>::
00606     _TrivialIterator_requirement_violation(__i);
00607   // Associated Types
00608   __difference_type_type_definition_requirement_violation<_InputIterator>();
00609   __reference_type_definition_requirement_violation<_InputIterator>();
00610   __pointer_type_definition_requirement_violation<_InputIterator>();
00611   __iterator_category_type_definition_requirement_violation<_InputIterator>();
00612   // Valid Expressions
00613   _STL_ERROR::__preincrement_operator_requirement_violation(__i);
00614   _STL_ERROR::__postincrement_operator_requirement_violation(__i);
00615 }
00616 };
00617 
00618 /* OutputIterator Requirements */
00619 
00620 template <class _OutputIterator>
00621 struct _OutputIterator_concept_specification {
00622 static void
00623 _OutputIterator_requirement_violation(_OutputIterator __i) {
00624   // Refinement of Assignable
00625   _Assignable_concept_specification<_OutputIterator>::
00626     _Assignable_requirement_violation(__i);
00627   // Associated Types
00628   __iterator_category_type_definition_requirement_violation<_OutputIterator>();
00629   // Valid Expressions
00630   _STL_ERROR::__dereference_operator_requirement_violation(__i);
00631   _STL_ERROR::__preincrement_operator_requirement_violation(__i);
00632   _STL_ERROR::__postincrement_operator_requirement_violation(__i);
00633   _STL_ERROR::
00634     __postincrement_operator_and_assignment_requirement_violation(__i, *__i);
00635 }
00636 };
00637 
00638 /* ForwardIterator Requirements */
00639 
00640 template <class _ForwardIterator>
00641 struct _ForwardIterator_concept_specification {
00642 static void
00643 _ForwardIterator_requirement_violation(_ForwardIterator __i) {
00644   // Refinement of InputIterator
00645   _InputIterator_concept_specification<_ForwardIterator>::
00646     _InputIterator_requirement_violation(__i);
00647 }
00648 };
00649 
00650 template <class _ForwardIterator>
00651 struct _Mutable_ForwardIterator_concept_specification {
00652 static void
00653 _Mutable_ForwardIterator_requirement_violation(_ForwardIterator __i) {
00654   _ForwardIterator_concept_specification<_ForwardIterator>::
00655     _ForwardIterator_requirement_violation(__i);
00656   // Refinement of OutputIterator
00657   _OutputIterator_concept_specification<_ForwardIterator>::
00658     _OutputIterator_requirement_violation(__i);
00659 }
00660 };
00661 
00662 /* BidirectionalIterator Requirements */
00663 
00664 template <class _BidirectionalIterator>
00665 struct _BidirectionalIterator_concept_specification {
00666 static void
00667 _BidirectionalIterator_requirement_violation(_BidirectionalIterator __i) {
00668   // Refinement of ForwardIterator
00669   _ForwardIterator_concept_specification<_BidirectionalIterator>::
00670     _ForwardIterator_requirement_violation(__i);
00671   // Valid Expressions
00672   _STL_ERROR::__predecrement_operator_requirement_violation(__i);
00673   _STL_ERROR::__postdecrement_operator_requirement_violation(__i);
00674 }
00675 };
00676 
00677 template <class _BidirectionalIterator>
00678 struct _Mutable_BidirectionalIterator_concept_specification {
00679 static void
00680 _Mutable_BidirectionalIterator_requirement_violation(
00681        _BidirectionalIterator __i)
00682 {
00683   _BidirectionalIterator_concept_specification<_BidirectionalIterator>::
00684     _BidirectionalIterator_requirement_violation(__i);
00685   // Refinement of mutable_ForwardIterator
00686   _Mutable_ForwardIterator_concept_specification<_BidirectionalIterator>::
00687     _Mutable_ForwardIterator_requirement_violation(__i);
00688   typedef typename
00689     __value_type_type_definition_requirement_violation<
00690     _BidirectionalIterator>::value_type __T;
00691   typename _Mutable_trait<__T>::_Type* __tmp_ptr = 0;
00692   // Valid Expressions
00693   _STL_ERROR::
00694     __postincrement_operator_and_assignment_requirement_violation(__i,
00695                                                                   *__tmp_ptr);
00696 }
00697 };
00698 
00699 /* RandomAccessIterator Requirements */
00700 
00701 template <class _RandAccIter>
00702 struct _RandomAccessIterator_concept_specification {
00703 static void
00704 _RandomAccessIterator_requirement_violation(_RandAccIter __i) {
00705   // Refinement of BidirectionalIterator
00706   _BidirectionalIterator_concept_specification<_RandAccIter>::
00707     _BidirectionalIterator_requirement_violation(__i);
00708   // Refinement of LessThanComparable
00709   _LessThanComparable_concept_specification<_RandAccIter>::
00710     _LessThanComparable_requirement_violation(__i);
00711   typedef typename 
00712         __value_type_type_definition_requirement_violation<_RandAccIter>
00713         ::value_type
00714     value_type;
00715   typedef typename
00716         __difference_type_type_definition_requirement_violation<_RandAccIter>
00717         ::difference_type 
00718     _Dist;
00719   typedef typename _Mutable_trait<_Dist>::_Type _MutDist;
00720 
00721   // Valid Expressions
00722   _STL_ERROR::__iterator_addition_assignment_requirement_violation(__i,
00723                                                                    _MutDist());
00724   _STL_ERROR::__iterator_addition_requirement_violation(__i,
00725                                                         _MutDist());
00726   _STL_ERROR::
00727     __iterator_subtraction_assignment_requirement_violation(__i,
00728                                                             _MutDist());
00729   _STL_ERROR::__iterator_subtraction_requirement_violation(__i,
00730                                                            _MutDist());
00731   _STL_ERROR::__difference_operator_requirement_violation(__i, __i,
00732                                                           _MutDist());
00733   typename _Mutable_trait<value_type>::_Type* __dummy_ptr = 0;
00734   _STL_ERROR::__element_access_operator_requirement_violation(__i,
00735                                                               __dummy_ptr,
00736                                                               _MutDist());
00737 }
00738 };
00739 
00740 template <class _RandAccIter>
00741 struct _Mutable_RandomAccessIterator_concept_specification {
00742 static void
00743 _Mutable_RandomAccessIterator_requirement_violation(_RandAccIter __i)
00744 {
00745   _RandomAccessIterator_concept_specification<_RandAccIter>::
00746     _RandomAccessIterator_requirement_violation(__i);
00747   // Refinement of mutable_BidirectionalIterator
00748   _Mutable_BidirectionalIterator_concept_specification<_RandAccIter>::
00749     _Mutable_BidirectionalIterator_requirement_violation(__i);
00750   typedef typename
00751         __value_type_type_definition_requirement_violation<_RandAccIter>
00752         ::value_type
00753     value_type;
00754   typedef typename
00755         __difference_type_type_definition_requirement_violation<_RandAccIter>
00756         ::difference_type
00757     _Dist;
00758 
00759   typename _Mutable_trait<value_type>::_Type* __tmp_ptr = 0;
00760   // Valid Expressions
00761   _STL_ERROR::__element_assignment_operator_requirement_violation(__i,
00762                   __tmp_ptr, _Dist());
00763 }
00764 };
00765 
00766 #define _STLP_TYPEDEF_REQUIREMENT(__REQUIREMENT) \
00767 template <class Type> \
00768 struct __##__REQUIREMENT##__typedef_requirement_violation { \
00769   typedef typename Type::__REQUIREMENT __REQUIREMENT; \
00770 };
00771 
00772 _STLP_TYPEDEF_REQUIREMENT(value_type);
00773 _STLP_TYPEDEF_REQUIREMENT(difference_type);
00774 _STLP_TYPEDEF_REQUIREMENT(size_type);
00775 _STLP_TYPEDEF_REQUIREMENT(reference);
00776 _STLP_TYPEDEF_REQUIREMENT(const_reference);
00777 _STLP_TYPEDEF_REQUIREMENT(pointer);
00778 _STLP_TYPEDEF_REQUIREMENT(const_pointer);
00779 
00780 
00781 template <class _Alloc>
00782 struct _Allocator_concept_specification {
00783 static void
00784 _Allocator_requirement_violation(_Alloc __a) {
00785   // Refinement of DefaultConstructible
00786   _DefaultConstructible_concept_specification<_Alloc>::
00787     _DefaultConstructible_requirement_violation(__a);
00788   // Refinement of EqualityComparable
00789   _EqualityComparable_concept_specification<_Alloc>::
00790     _EqualityComparable_requirement_violation(__a);
00791   // Associated Types
00792   __value_type__typedef_requirement_violation<_Alloc>();
00793   __difference_type__typedef_requirement_violation<_Alloc>();
00794   __size_type__typedef_requirement_violation<_Alloc>();
00795   __reference__typedef_requirement_violation<_Alloc>();
00796   __const_reference__typedef_requirement_violation<_Alloc>();
00797   __pointer__typedef_requirement_violation<_Alloc>();
00798   __const_pointer__typedef_requirement_violation<_Alloc>();
00799   typedef typename _Alloc::value_type _Type;
00800   _STLP_REQUIRES_SAME_TYPE(typename _Alloc::rebind<_Type>::other, _Alloc);
00801 }
00802 };
00803 
00804 #endif /* _STLP_USE_CONCEPT_CHECKS */
00805 
00806 #endif /* __CONCEPT_CHECKS_H */
00807 
00808 // Local Variables:
00809 // mode:C++
00810 // End:

Generated on Mon Jun 5 10:20:43 2006 for Intelligence.kdevelop by  doxygen 1.4.6