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