container_concepts.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 __STL_CONTAINER_CONCEPTS_H
00015 #define __STL_CONTAINER_CONCEPTS_H
00016 
00017 
00018 #include <concept_checks.h>
00019 
00020 #ifdef __STL_USE_CONCEPT_CHECKS
00021 
00022 
00023 // This file covers the following concepts:
00024 //       _Container
00025 //       _ForwardContainer
00026 //       _ReversibleContainer
00027 //       _const_ReversibleContainer
00028 //       _RandomAccessContainer
00029 //
00030 
00031 struct _ERROR_IN_STL_CONTAINER {
00032 
00033   /* Container expresssions */
00034 
00035   template <class _Container>
00036   static void
00037   __begin_iterator_accessor_requirement_violation(_Container __c) {
00038     __c.begin();
00039   }
00040   template <class _Container>
00041   static void
00042   __const_begin_iterator_accessor_requirement_violation(const _Container& __c) {
00043     __c.begin();
00044   }
00045   template <class _Container>
00046   static void
00047   __end_iterator_accessor_requirement_violation(_Container __c) {
00048     __c.end();
00049   }
00050   template <class _Container>
00051   static void
00052   __const_end_iterator_accessor_requirement_violation(const _Container& __c) {
00053     __c.end();
00054   }
00055 
00056   template <class _Container>
00057   static void
00058   __rbegin_iterator_accessor_requirement_violation(_Container __c) {
00059     __c.rbegin();
00060   }
00061   template <class _Container>
00062   static void
00063   __const_rbegin_iterator_accessor_requirement_violation(const _Container& __c) {
00064     __c.rbegin();
00065   }
00066   template <class _Container>
00067   static void
00068   __rend_iterator_accessor_requirement_violation(_Container __c) {
00069     __c.rend();
00070   }
00071   template <class _Container>
00072   static void
00073   __const_rend_iterator_accessor_requirement_violation(const _Container& __c) {
00074     __c.rend();
00075   }
00076   template <class _Container>
00077   static void
00078   __size_function_must_be_const(const _Container& __c) {
00079     __c.size();
00080   }
00081   template <class _Container>
00082   static void
00083   __size_function_requirement_violation(_Container& __c) {
00084     __c.size();
00085     __size_function_must_be_const(__c);
00086   }
00087   template <class _Container>
00088   static void
00089   __max_size_function_must_be_const(const _Container& __c) {
00090     __c.max_size();
00091   }
00092   template <class _Container>
00093   static void
00094   __max_size_function_requirement_violation(_Container& __c) {
00095     __c.max_size();
00096     __max_size_function_must_be_const(__c);
00097   }
00098   template <class _Container>
00099   static void
00100   __empty_function_must_be_const(const _Container& __c) {
00101     __c.empty();
00102   }
00103   template <class _Container>
00104   static void
00105   __empty_function_requirement_violation(_Container& __c) {
00106     __c.empty();
00107     __empty_function_must_be_const(__c);
00108   }
00109   template <class _Container>
00110   static void
00111   __swap_function_requirement_violation(_Container& __c) {
00112     __c.swap(__c);
00113   }
00114 
00115 };
00116 
00117 
00118 __STL_TYPEDEF_REQUIREMENT(iterator);
00119 __STL_TYPEDEF_REQUIREMENT(const_iterator);
00120 
00121 /* Containers */
00122 
00123 template <class _Container>
00124 struct _Container_concept_specification {
00125 static void
00126 _Container_requirement_violation(_Container __c) {
00127   // Refinement of Assignable
00128   _Assignable_concept_specification<_Container>::_Assignable_requirement_violation(__c);
00129   // Associated Types
00130   __value_type__typedef_requirement_violation<_Container>();
00131   __difference_type__typedef_requirement_violation<_Container>();
00132   __size_type__typedef_requirement_violation<_Container>();
00133   __reference__typedef_requirement_violation<_Container>();
00134   __const_reference__typedef_requirement_violation<_Container>();
00135   __pointer__typedef_requirement_violation<_Container>();
00136   __const_pointer__typedef_requirement_violation<_Container>();
00137   __iterator__typedef_requirement_violation<_Container>();
00138   __const_iterator__typedef_requirement_violation<_Container>();
00139   // Valid Expressions
00140   _ERROR_IN_STL_CONTAINER::__const_begin_iterator_accessor_requirement_violation(__c);
00141   _ERROR_IN_STL_CONTAINER::__const_end_iterator_accessor_requirement_violation(__c);
00142   _ERROR_IN_STL_CONTAINER::__begin_iterator_accessor_requirement_violation(__c);
00143   _ERROR_IN_STL_CONTAINER::__end_iterator_accessor_requirement_violation(__c);
00144   _ERROR_IN_STL_CONTAINER::__size_function_requirement_violation(__c);
00145   _ERROR_IN_STL_CONTAINER::__max_size_function_requirement_violation(__c);
00146   _ERROR_IN_STL_CONTAINER::__empty_function_requirement_violation(__c);
00147   _ERROR_IN_STL_CONTAINER::__swap_function_requirement_violation(__c);
00148   // Requirements on Iterators
00149   typedef typename _Container::iterator iter;
00150   typedef typename _Container::const_iterator const_iter;
00151   _InputIterator_concept_specification<const_iter>::_InputIterator_requirement_violation(const_iter());
00152   _InputIterator_concept_specification<iter>::_InputIterator_requirement_violation(iter());
00153 }
00154 };
00155 
00156 template <class _ForwardContainer>
00157 struct _ForwardContainer_concept_specification {
00158 static void
00159 _ForwardContainer_requirement_violation(_ForwardContainer __c) {
00160   // Refinement of Container
00161   _Container_concept_specification<_ForwardContainer>::_Container_requirement_violation(__c);
00162   // Requirements on Iterators
00163   typedef typename _ForwardContainer::iterator iter;
00164   typedef typename _ForwardContainer::const_iterator const_iter;
00165   _ForwardIterator_concept_specification<const_iter>::_ForwardIterator_requirement_violation(const_iter());
00166   _Mutable_ForwardIterator_concept_specification<iter>::_Mutable_ForwardIterator_requirement_violation(iter());
00167 }
00168 };
00169 
00170 
00171 __STL_TYPEDEF_REQUIREMENT(reverse_iterator);
00172 __STL_TYPEDEF_REQUIREMENT(const_reverse_iterator);
00173 
00174 template <class _ReversibleContainer>
00175 struct _ReversibleContainer_concept_specification {
00176 static void
00177 _ReversibleContainer_requirement_violation(_ReversibleContainer __c) {
00178   // Refinement of ForwardContainer
00179   _ForwardContainer_concept_specification<_ReversibleContainer>::_ForwardContainer_requirement_violation(__c);
00180   // Associated types
00181   __reverse_iterator__typedef_requirement_violation<_ReversibleContainer>();
00182   __const_reverse_iterator__typedef_requirement_violation<_ReversibleContainer>();
00183   // Valid Expressions
00184   _ERROR_IN_STL_CONTAINER::__const_rbegin_iterator_accessor_requirement_violation(__c);
00185   _ERROR_IN_STL_CONTAINER::__const_rend_iterator_accessor_requirement_violation(__c);
00186   _ERROR_IN_STL_CONTAINER::__rbegin_iterator_accessor_requirement_violation(__c);
00187   _ERROR_IN_STL_CONTAINER::__rend_iterator_accessor_requirement_violation(__c);
00188   // Requirements on Iterators
00189   typedef typename _ReversibleContainer::iterator iter;
00190   typedef typename _ReversibleContainer::const_iterator const_iter;
00191   _BidirectionalIterator_concept_specification<const_iter>::_BidirectionalIterator_requirement_violation(const_iter());
00192   _Mutable_BidirectionalIterator_concept_specification<iter>::_Mutable_BidirectionalIterator_requirement_violation(iter());
00193 }
00194 };
00195 
00196 template <class _ReversibleContainer>
00197 struct _const_ReversibleContainer_concept_specification {
00198 static void
00199 _const_ReversibleContainer_requirement_violation(_ReversibleContainer __c) {
00200   // Refinement of Container (JGS, not ForwardContainer)
00201   _Container_concept_specification<_ReversibleContainer>::_Container_requirement_violation(__c);
00202   // Associated types
00203   __reverse_iterator__typedef_requirement_violation<_ReversibleContainer>();
00204   __const_reverse_iterator__typedef_requirement_violation<_ReversibleContainer>();
00205   // Valid Expressions
00206   _ERROR_IN_STL_CONTAINER::__const_rbegin_iterator_accessor_requirement_violation(__c);
00207   _ERROR_IN_STL_CONTAINER::__const_rend_iterator_accessor_requirement_violation(__c);
00208   _ERROR_IN_STL_CONTAINER::__rbegin_iterator_accessor_requirement_violation(__c);
00209   _ERROR_IN_STL_CONTAINER::__rend_iterator_accessor_requirement_violation(__c);
00210   // Requirements on Iterators
00211   typedef typename _ReversibleContainer::iterator iter;
00212   typedef typename _ReversibleContainer::const_iterator const_iter;
00213   
00214   // This line won't compile on gcc 2.91 due to a compiler bug.
00215 #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 91)
00216   __BidirectionalIterator_concept_specification<const_iter>::_BidirectionalIterator_requirement_violation(const_iter());
00217 #endif
00218 }
00219 };
00220 
00221 
00222 template <class _RandomAccessContainer>
00223 struct _RandomAccessContainer_concept_specification {
00224 static void
00225 _RandomAccessContainer_requirement_violation(_RandomAccessContainer __c) {
00226   // Refinement of ReversibleContainer
00227   _ReversibleContainer_concept_specification<_RandomAccessContainer>::_ReversibleContainer_requirement_violation(__c);
00228   // Valid Expressions
00229   typedef typename _RandomAccessContainer::value_type __T;
00230   typedef typename _RandomAccessContainer::difference_type _Dist;
00231   typedef typename _Mutable_trait<__T>::_Type Type;
00232   typedef Type* _TypePtr;
00233   typedef typename _Mutable_trait<_Dist>::_Type Dist;
00234   _STL_ERROR::__element_access_operator_requirement_violation(__c,
00235                                                               _TypePtr(), 
00236                                                               Dist());
00237   // Requirements on Iterators
00238   typedef typename _RandomAccessContainer::iterator iter;
00239   typedef typename _RandomAccessContainer::const_iterator const_iter;
00240   _RandomAccessIterator_concept_specification<const_iter>::_RandomAccessIterator_requirement_violation(const_iter());
00241   _Mutable_RandomAccessIterator_concept_specification<iter>::_Mutable_RandomAccessIterator_requirement_violation(iter());
00242 }
00243 };
00244 
00245 #endif /* if __STL_USE_CONCEPT_CHECKS */
00246 
00247 #endif /* __STL_CONTAINER_CONCEPTS_H */

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