Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

boost_concept_check.h

Go to the documentation of this file.
00001 //
00002 // (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify,
00003 // sell and distribute this software is granted provided this
00004 // copyright notice appears in all copies. This software is provided
00005 // "as is" without express or implied warranty, and with no claim as
00006 // to its suitability for any purpose.
00007 //
00008 
00009 // GCC Note:  based on version 1.12.0 of the Boost library.
00010 #ifndef _GLIBCPP_BOOST_CONCEPT_CHECK
00011 #define _GLIBCPP_BOOST_CONCEPT_CHECK 1
00012 
00013 #pragma GCC system_header
00014 #include <bits/stl_iterator_base_types.h>    // for traits and tags
00015 #include <utility>                           // for pair<>
00016 
00017 
00018 namespace __gnu_cxx
00019 {
00020 
00021 #define _IsUnused __attribute__ ((__unused__))
00022 
00023 template <class _Concept>
00024 inline void __function_requires()
00025 {
00026   void (_Concept::*__x)() _IsUnused = &_Concept::__constraints;
00027 }
00028 
00029 
00030 // ??? Should the "concept_checking*" structs begin with more than _ ?
00031 #define _GLIBCPP_CLASS_REQUIRES(_type_var, _ns, _concept) \
00032   typedef void (_ns::_concept <_type_var>::* _func##_type_var##_concept)(); \
00033   template <_func##_type_var##_concept _Tp1> \
00034   struct _concept_checking##_type_var##_concept { }; \
00035   typedef _concept_checking##_type_var##_concept< \
00036     &_ns::_concept <_type_var>::__constraints> \
00037     _concept_checking_typedef##_type_var##_concept
00038 
00039 #define _GLIBCPP_CLASS_REQUIRES2(_type_var1, _type_var2, _ns, _concept) \
00040   typedef void (_ns::_concept <_type_var1,_type_var2>::* _func##_type_var1##_type_var2##_concept)(); \
00041   template <_func##_type_var1##_type_var2##_concept _Tp1> \
00042   struct _concept_checking##_type_var1##_type_var2##_concept { }; \
00043   typedef _concept_checking##_type_var1##_type_var2##_concept< \
00044     &_ns::_concept <_type_var1,_type_var2>::__constraints> \
00045     _concept_checking_typedef##_type_var1##_type_var2##_concept
00046 
00047 #define _GLIBCPP_CLASS_REQUIRES3(_type_var1, _type_var2, _type_var3, _ns, _concept) \
00048   typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3>::* _func##_type_var1##_type_var2##_type_var3##_concept)(); \
00049   template <_func##_type_var1##_type_var2##_type_var3##_concept _Tp1> \
00050   struct _concept_checking##_type_var1##_type_var2##_type_var3##_concept { }; \
00051   typedef _concept_checking##_type_var1##_type_var2##_type_var3##_concept< \
00052     &_ns::_concept <_type_var1,_type_var2,_type_var3>::__constraints>  \
00053   _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_concept
00054 
00055 #define _GLIBCPP_CLASS_REQUIRES4(_type_var1, _type_var2, _type_var3, _type_var4, _ns, _concept) \
00056   typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::* _func##_type_var1##_type_var2##_type_var3##_type_var4##_concept)(); \
00057   template <_func##_type_var1##_type_var2##_type_var3##_type_var4##_concept _Tp1> \
00058   struct _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept { }; \
00059   typedef _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept< \
00060   &_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::__constraints> \
00061     _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_type_var4##_concept
00062 
00063 
00064 template <class _Tp1, class _Tp2>
00065 struct _Aux_require_same { };
00066 
00067 template <class _Tp>
00068 struct _Aux_require_same<_Tp,_Tp> { typedef _Tp _Type; };
00069 
00070   template <class _Tp1, class _Tp2>
00071   struct _SameTypeConcept
00072   {
00073     void __constraints() {
00074       typedef typename _Aux_require_same<_Tp1, _Tp2>::_Type _Required;
00075     }
00076   };
00077 
00078   template <class _Tp>
00079   struct _IntegerConcept {
00080     void __constraints() { 
00081       __error_type_must_be_an_integer_type();
00082     }
00083   };
00084   template <> struct _IntegerConcept<short> { void __constraints() {} };
00085   template <> struct _IntegerConcept<unsigned short> { void __constraints(){} };
00086   template <> struct _IntegerConcept<int> { void __constraints() {} };
00087   template <> struct _IntegerConcept<unsigned int> { void __constraints() {} };
00088   template <> struct _IntegerConcept<long> { void __constraints() {} };
00089   template <> struct _IntegerConcept<unsigned long> { void __constraints() {} };
00090 #ifdef _GLIBCPP_USE_LONG_LONG
00091   template <> struct _IntegerConcept<long long> { void __constraints() {} };
00092   template <> struct _IntegerConcept<unsigned long long>
00093                                                 { void __constraints() {} };
00094 #endif
00095 
00096   template <class _Tp>
00097   struct _SignedIntegerConcept {
00098     void __constraints() { 
00099       __error_type_must_be_a_signed_integer_type();
00100     }
00101   };
00102   template <> struct _SignedIntegerConcept<short> { void __constraints() {} };
00103   template <> struct _SignedIntegerConcept<int> { void __constraints() {} };
00104   template <> struct _SignedIntegerConcept<long> { void __constraints() {} };
00105 #ifdef _GLIBCPP_USE_LONG_LONG
00106   template <> struct _SignedIntegerConcept<long long> { void __constraints(){}};
00107 #endif
00108 
00109   template <class _Tp>
00110   struct _UnsignedIntegerConcept {
00111     void __constraints() { 
00112       __error_type_must_be_an_unsigned_integer_type();
00113     }
00114   };
00115   template <> struct _UnsignedIntegerConcept<unsigned short>
00116     { void __constraints() {} };
00117   template <> struct _UnsignedIntegerConcept<unsigned int>
00118     { void __constraints() {} };
00119   template <> struct _UnsignedIntegerConcept<unsigned long>
00120     { void __constraints() {} };
00121 #ifdef _GLIBCPP_USE_LONG_LONG
00122   template <> struct _UnsignedIntegerConcept<unsigned long long>
00123     { void __constraints() {} };
00124 #endif
00125 
00126   //===========================================================================
00127   // Basic Concepts
00128 
00129   template <class _Tp>
00130   struct _DefaultConstructibleConcept
00131   {
00132     void __constraints() {
00133       _Tp __a _IsUnused;                // require default constructor
00134     }
00135   };
00136 
00137   template <class _Tp>
00138   struct _AssignableConcept
00139   {
00140     void __constraints() {
00141       __a = __a;                        // require assignment operator
00142       __const_constraints(__a);
00143     }
00144     void __const_constraints(const _Tp& __b) {
00145       __a = __b;                   // const required for argument to assignment
00146     }
00147     _Tp __a;
00148   };
00149 
00150   template <class _Tp>
00151   struct _CopyConstructibleConcept
00152   {
00153     void __constraints() {
00154       _Tp __a(__b);                     // require copy constructor
00155       _Tp* __ptr _IsUnused = &__a;      // require address of operator
00156       __const_constraints(__a);
00157     }
00158     void __const_constraints(const _Tp& __a) {
00159       _Tp __c(__a) _IsUnused;           // require const copy constructor
00160       const _Tp* __ptr _IsUnused = &__a; // require const address of operator
00161     }
00162     _Tp __b;
00163   };
00164 
00165   // The SGI STL version of Assignable requires copy constructor and operator=
00166   template <class _Tp>
00167   struct _SGIAssignableConcept
00168   {
00169     void __constraints() {
00170       _Tp __b(__a) _IsUnused;
00171       __a = __a;                        // require assignment operator
00172       __const_constraints(__a);
00173     }
00174     void __const_constraints(const _Tp& __b) {
00175       _Tp __c(__b) _IsUnused;
00176       __a = __b;              // const required for argument to assignment
00177     }
00178     _Tp __a;
00179   };
00180 
00181   template <class _From, class _To>
00182   struct _ConvertibleConcept
00183   {
00184     void __constraints() {
00185       _To __y _IsUnused = __x;
00186     }
00187     _From __x;
00188   };
00189 
00190   // The C++ standard requirements for many concepts talk about return
00191   // types that must be "convertible to bool".  The problem with this
00192   // requirement is that it leaves the door open for evil proxies that
00193   // define things like operator|| with strange return types.  Two
00194   // possible solutions are:
00195   // 1) require the return type to be exactly bool
00196   // 2) stay with convertible to bool, and also
00197   //    specify stuff about all the logical operators.
00198   // For now we just test for convertible to bool.
00199   template <class _Tp>
00200   void __aux_require_boolean_expr(const _Tp& __t) {
00201     bool __x _IsUnused = __t;
00202   }
00203 
00204 // FIXME
00205   template <class _Tp>
00206   struct _EqualityComparableConcept
00207   {
00208     void __constraints() {
00209       __aux_require_boolean_expr(__a == __b);
00210       __aux_require_boolean_expr(__a != __b);
00211     }
00212     _Tp __a, __b;
00213   };
00214 
00215   template <class _Tp>
00216   struct _LessThanComparableConcept
00217   {
00218     void __constraints() {
00219       __aux_require_boolean_expr(__a < __b);
00220     }
00221     _Tp __a, __b;
00222   };
00223 
00224   // This is equivalent to SGI STL's LessThanComparable.
00225   template <class _Tp>
00226   struct _ComparableConcept
00227   {
00228     void __constraints() {
00229       __aux_require_boolean_expr(__a < __b);
00230       __aux_require_boolean_expr(__a > __b);
00231       __aux_require_boolean_expr(__a <= __b);
00232       __aux_require_boolean_expr(__a >= __b);
00233     }
00234     _Tp __a, __b;
00235   };
00236 
00237 #define _GLIBCPP_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(_OP,_NAME) \
00238   template <class _First, class _Second> \
00239   struct _NAME { \
00240     void __constraints() { (void)__constraints_(); } \
00241     bool __constraints_() {  \
00242       return  __a _OP __b; \
00243     } \
00244     _First __a; \
00245     _Second __b; \
00246   }
00247 
00248 #define _GLIBCPP_DEFINE_BINARY_OPERATOR_CONSTRAINT(_OP,_NAME) \
00249   template <class _Ret, class _First, class _Second> \
00250   struct _NAME { \
00251     void __constraints() { (void)__constraints_(); } \
00252     _Ret __constraints_() {  \
00253       return __a _OP __b; \
00254     } \
00255     _First __a; \
00256     _Second __b; \
00257   }
00258 
00259   _GLIBCPP_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(==, _EqualOpConcept);
00260   _GLIBCPP_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(!=, _NotEqualOpConcept);
00261   _GLIBCPP_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<, _LessThanOpConcept);
00262   _GLIBCPP_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<=, _LessEqualOpConcept);
00263   _GLIBCPP_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>, _GreaterThanOpConcept);
00264   _GLIBCPP_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>=, _GreaterEqualOpConcept);
00265 
00266   _GLIBCPP_DEFINE_BINARY_OPERATOR_CONSTRAINT(+, _PlusOpConcept);
00267   _GLIBCPP_DEFINE_BINARY_OPERATOR_CONSTRAINT(*, _TimesOpConcept);
00268   _GLIBCPP_DEFINE_BINARY_OPERATOR_CONSTRAINT(/, _DivideOpConcept);
00269   _GLIBCPP_DEFINE_BINARY_OPERATOR_CONSTRAINT(-, _SubtractOpConcept);
00270   _GLIBCPP_DEFINE_BINARY_OPERATOR_CONSTRAINT(%, _ModOpConcept);
00271 
00272 #undef _GLIBCPP_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT
00273 #undef _GLIBCPP_DEFINE_BINARY_OPERATOR_CONSTRAINT
00274 
00275   //===========================================================================
00276   // Function Object Concepts
00277 
00278   template <class _Func, class _Return>
00279   struct _GeneratorConcept
00280   {
00281     void __constraints() {
00282       const _Return& __r _IsUnused = __f();// require operator() member function
00283     }
00284     _Func __f;
00285   };
00286 
00287 
00288   template <class _Func>
00289   struct _GeneratorConcept<_Func,void>
00290   {
00291     void __constraints() {
00292       __f();                            // require operator() member function
00293     }
00294     _Func __f;
00295   };
00296 
00297   template <class _Func, class _Return, class _Arg>
00298   struct _UnaryFunctionConcept
00299   {
00300     void __constraints() {
00301       __r = __f(__arg);                  // require operator()
00302     }
00303     _Func __f;
00304     _Arg __arg;
00305     _Return __r;
00306   };
00307 
00308   template <class _Func, class _Arg>
00309   struct _UnaryFunctionConcept<_Func, void, _Arg> {
00310     void __constraints() { 
00311       __f(__arg);                       // require operator()
00312     }
00313     _Func __f;
00314     _Arg __arg;
00315   };
00316 
00317   template <class _Func, class _Return, class _First, class _Second>
00318   struct _BinaryFunctionConcept
00319   {
00320     void __constraints() { 
00321       __r = __f(__first, __second);     // require operator()
00322     }
00323     _Func __f;
00324     _First __first;
00325     _Second __second;
00326     _Return __r;
00327   };
00328 
00329   template <class _Func, class _First, class _Second>
00330   struct _BinaryFunctionConcept<_Func, void, _First, _Second>
00331   {
00332     void __constraints() {
00333       __f(__first, __second);           // require operator()
00334     }
00335     _Func __f;
00336     _First __first;
00337     _Second __second;
00338   };
00339 
00340   template <class _Func, class _Arg>
00341   struct _UnaryPredicateConcept
00342   {
00343     void __constraints() {
00344       __aux_require_boolean_expr(__f(__arg)); // require op() returning bool
00345     }
00346     _Func __f;
00347     _Arg __arg;
00348   };
00349 
00350   template <class _Func, class _First, class _Second>
00351   struct _BinaryPredicateConcept
00352   {
00353     void __constraints() {
00354       __aux_require_boolean_expr(__f(__a, __b)); // require op() returning bool
00355     }
00356     _Func __f;
00357     _First __a;
00358     _Second __b;
00359   };
00360 
00361   // use this when functor is used inside a container class like std::set
00362   template <class _Func, class _First, class _Second>
00363   struct _Const_BinaryPredicateConcept {
00364     void __constraints() { 
00365       __const_constraints(__f);
00366     }
00367     void __const_constraints(const _Func& __fun) {
00368       __function_requires<_BinaryPredicateConcept<_Func, _First, _Second> >();
00369       // operator() must be a const member function
00370       __aux_require_boolean_expr(__fun(__a, __b));
00371     }
00372     _Func __f;
00373     _First __a;
00374     _Second __b;
00375   };
00376 
00377   //===========================================================================
00378   // Iterator Concepts
00379 
00380   template <class _Tp>
00381   struct _TrivialIteratorConcept
00382   {
00383     void __constraints() {
00384       __function_requires< _DefaultConstructibleConcept<_Tp> >();
00385       __function_requires< _AssignableConcept<_Tp> >();
00386       __function_requires< _EqualityComparableConcept<_Tp> >();
00387       typedef typename std::iterator_traits<_Tp>::value_type _V;
00388       (void)*__i;                       // require dereference operator
00389     }
00390     _Tp __i;
00391   };
00392 
00393   template <class _Tp>
00394   struct _Mutable_TrivialIteratorConcept
00395   {
00396     void __constraints() {
00397       __function_requires< _TrivialIteratorConcept<_Tp> >();
00398       *__i = *__j;                      // require dereference and assignment
00399     }
00400     _Tp __i, __j;
00401   };
00402 
00403   template <class _Tp>
00404   struct _InputIteratorConcept
00405   {
00406     void __constraints() {
00407       __function_requires< _TrivialIteratorConcept<_Tp> >();
00408       // require iterator_traits typedef's
00409       typedef typename std::iterator_traits<_Tp>::difference_type _D;
00410       __function_requires< _SignedIntegerConcept<_D> >();
00411       typedef typename std::iterator_traits<_Tp>::reference _R;
00412       typedef typename std::iterator_traits<_Tp>::pointer _Pt;
00413       typedef typename std::iterator_traits<_Tp>::iterator_category _Cat;
00414       __function_requires< _ConvertibleConcept<
00415         typename std::iterator_traits<_Tp>::iterator_category,
00416         std::input_iterator_tag> >();
00417       ++__i;                            // require preincrement operator
00418       __i++;                            // require postincrement operator
00419     }
00420     _Tp __i;
00421   };
00422 
00423   template <class _Tp, class _ValueT>
00424   struct _OutputIteratorConcept
00425   {
00426     void __constraints() {
00427       __function_requires< _AssignableConcept<_Tp> >();
00428       ++__i;                            // require preincrement operator
00429       __i++;                            // require postincrement operator
00430       *__i++ = __t;                     // require postincrement and assignment
00431     }
00432     _Tp __i;
00433     _ValueT __t;
00434   };
00435 
00436   template <class _Tp>
00437   struct _ForwardIteratorConcept
00438   {
00439     void __constraints() {
00440       __function_requires< _InputIteratorConcept<_Tp> >();
00441       __function_requires< _ConvertibleConcept<
00442         typename std::iterator_traits<_Tp>::iterator_category,
00443         std::forward_iterator_tag> >();
00444       typedef typename std::iterator_traits<_Tp>::reference _R;
00445       _R __r _IsUnused = *__i;
00446     }
00447     _Tp __i;
00448   };
00449 
00450   template <class _Tp>
00451   struct _Mutable_ForwardIteratorConcept
00452   {
00453     void __constraints() {
00454       __function_requires< _ForwardIteratorConcept<_Tp> >();
00455       *__i++ = *__i;                    // require postincrement and assignment
00456     }
00457     _Tp __i;
00458   };
00459 
00460   template <class _Tp>
00461   struct _BidirectionalIteratorConcept
00462   {
00463     void __constraints() {
00464       __function_requires< _ForwardIteratorConcept<_Tp> >();
00465       __function_requires< _ConvertibleConcept<
00466         typename std::iterator_traits<_Tp>::iterator_category,
00467         std::bidirectional_iterator_tag> >();
00468       --__i;                            // require predecrement operator
00469       __i--;                            // require postdecrement operator
00470     }
00471     _Tp __i;
00472   };
00473 
00474   template <class _Tp>
00475   struct _Mutable_BidirectionalIteratorConcept
00476   {
00477     void __constraints() {
00478       __function_requires< _BidirectionalIteratorConcept<_Tp> >();
00479       __function_requires< _Mutable_ForwardIteratorConcept<_Tp> >();
00480       *__i-- = *__i;                    // require postdecrement and assignment
00481     }
00482     _Tp __i;
00483   };
00484 
00485 
00486   template <class _Tp>
00487   struct _RandomAccessIteratorConcept
00488   {
00489     void __constraints() {
00490       __function_requires< _BidirectionalIteratorConcept<_Tp> >();
00491       __function_requires< _ComparableConcept<_Tp> >();
00492       __function_requires< _ConvertibleConcept<
00493         typename std::iterator_traits<_Tp>::iterator_category,
00494         std::random_access_iterator_tag> >();
00495       // ??? We don't use _R, are we just checking for "referenceability"?
00496       typedef typename std::iterator_traits<_Tp>::reference _R;
00497 
00498       __i += __n;                       // require assignment addition operator
00499       __i = __i + __n; __i = __n + __i; // require addition with difference type
00500       __i -= __n;                       // require assignment subtraction op
00501       __i = __i - __n;                  // require subtraction with
00502                                         //            difference type
00503       __n = __i - __j;                  // require difference operator
00504       (void)__i[__n];                   // require element access operator
00505     }
00506     _Tp __a, __b;
00507     _Tp __i, __j;
00508     typename std::iterator_traits<_Tp>::difference_type __n;
00509   };
00510 
00511   template <class _Tp>
00512   struct _Mutable_RandomAccessIteratorConcept
00513   {
00514     void __constraints() {
00515       __function_requires< _RandomAccessIteratorConcept<_Tp> >();
00516       __function_requires< _Mutable_BidirectionalIteratorConcept<_Tp> >();
00517       __i[__n] = *__i;                  // require element access and assignment
00518     }
00519     _Tp __i;
00520     typename std::iterator_traits<_Tp>::difference_type __n;
00521   };
00522 
00523   //===========================================================================
00524   // Container Concepts
00525 
00526   template <class _Container>
00527   struct _ContainerConcept
00528   {
00529     typedef typename _Container::value_type _Value_type;
00530     typedef typename _Container::difference_type _Difference_type;
00531     typedef typename _Container::size_type _Size_type;
00532     typedef typename _Container::const_reference _Const_reference;
00533     typedef typename _Container::const_pointer _Const_pointer;
00534     typedef typename _Container::const_iterator _Const_iterator;
00535 
00536     void __constraints() {
00537       __function_requires< _InputIteratorConcept<_Const_iterator> >();
00538       __function_requires< _AssignableConcept<_Container> >();
00539       const _Container __c;
00540       __i = __c.begin();
00541       __i = __c.end();
00542       __n = __c.size();
00543       __n = __c.max_size();
00544       __b = __c.empty();
00545     }
00546     bool __b;
00547     _Const_iterator __i;
00548     _Size_type __n;
00549   };
00550 
00551   template <class _Container>
00552   struct _Mutable_ContainerConcept
00553   {
00554     typedef typename _Container::value_type _Value_type;
00555     typedef typename _Container::reference _Reference;
00556     typedef typename _Container::iterator _Iterator;
00557     typedef typename _Container::pointer _Pointer;
00558     
00559     void __constraints() {
00560       __function_requires< _ContainerConcept<_Container> >();
00561       __function_requires< _AssignableConcept<_Value_type> >();
00562       __function_requires< _InputIteratorConcept<_Iterator> >();
00563 
00564       __i = __c.begin();
00565       __i = __c.end();
00566       __c.swap(__c2);
00567     }
00568     _Iterator __i;
00569     _Container __c, __c2;
00570   };
00571 
00572   template <class _ForwardContainer>
00573   struct _ForwardContainerConcept
00574   {
00575     void __constraints() {
00576       __function_requires< _ContainerConcept<_ForwardContainer> >();
00577       typedef typename _ForwardContainer::const_iterator _Const_iterator;
00578       __function_requires< _ForwardIteratorConcept<_Const_iterator> >();
00579     }
00580   };  
00581 
00582   template <class _ForwardContainer>
00583   struct _Mutable_ForwardContainerConcept
00584   {
00585     void __constraints() {
00586       __function_requires< _ForwardContainerConcept<_ForwardContainer> >();
00587       __function_requires< _Mutable_ContainerConcept<_ForwardContainer> >();
00588       typedef typename _ForwardContainer::iterator _Iterator;
00589       __function_requires< _Mutable_ForwardIteratorConcept<_Iterator> >();
00590     }
00591   };  
00592 
00593   template <class _ReversibleContainer>
00594   struct _ReversibleContainerConcept
00595   {
00596     typedef typename _ReversibleContainer::const_iterator _Const_iterator;
00597     typedef typename _ReversibleContainer::const_reverse_iterator
00598       _Const_reverse_iterator;
00599 
00600     void __constraints() {
00601       __function_requires< _ForwardContainerConcept<_ReversibleContainer> >();
00602       __function_requires< _BidirectionalIteratorConcept<_Const_iterator> >();
00603       __function_requires<
00604         _BidirectionalIteratorConcept<_Const_reverse_iterator> >();
00605 
00606       const _ReversibleContainer __c;
00607       _Const_reverse_iterator __i = __c.rbegin();
00608       __i = __c.rend();
00609     }
00610   };
00611 
00612   template <class _ReversibleContainer>
00613   struct _Mutable_ReversibleContainerConcept
00614   {
00615     typedef typename _ReversibleContainer::iterator _Iterator;
00616     typedef typename _ReversibleContainer::reverse_iterator _Reverse_iterator;
00617 
00618     void __constraints() {
00619       __function_requires<_ReversibleContainerConcept<_ReversibleContainer> >();
00620       __function_requires<
00621         _Mutable_ForwardContainerConcept<_ReversibleContainer> >();
00622       __function_requires<_Mutable_BidirectionalIteratorConcept<_Iterator> >();
00623       __function_requires<
00624         _Mutable_BidirectionalIteratorConcept<_Reverse_iterator> >();
00625 
00626       _Reverse_iterator __i = __c.rbegin();
00627       __i = __c.rend();
00628     }
00629     _ReversibleContainer __c;
00630   };
00631 
00632   template <class _RandomAccessContainer>
00633   struct _RandomAccessContainerConcept
00634   {
00635     typedef typename _RandomAccessContainer::size_type _Size_type;
00636     typedef typename _RandomAccessContainer::const_reference _Const_reference;
00637     typedef typename _RandomAccessContainer::const_iterator _Const_iterator;
00638     typedef typename _RandomAccessContainer::const_reverse_iterator
00639       _Const_reverse_iterator;
00640 
00641     void __constraints() {
00642       __function_requires<
00643         _ReversibleContainerConcept<_RandomAccessContainer> >();
00644       __function_requires< _RandomAccessIteratorConcept<_Const_iterator> >();
00645       __function_requires<
00646         _RandomAccessIteratorConcept<_Const_reverse_iterator> >();
00647 
00648       const _RandomAccessContainer __c;
00649       _Const_reference __r _IsUnused = __c[__n];
00650     }
00651     _Size_type __n;
00652   };
00653 
00654   template <class _RandomAccessContainer>
00655   struct _Mutable_RandomAccessContainerConcept
00656   {
00657     typedef typename _RandomAccessContainer::size_type _Size_type;
00658     typedef typename _RandomAccessContainer::reference _Reference;
00659     typedef typename _RandomAccessContainer::iterator _Iterator;
00660     typedef typename _RandomAccessContainer::reverse_iterator _Reverse_iterator;
00661 
00662     void __constraints() {
00663       __function_requires<
00664         _RandomAccessContainerConcept<_RandomAccessContainer> >();
00665       __function_requires<
00666         _Mutable_ReversibleContainerConcept<_RandomAccessContainer> >();
00667       __function_requires< _Mutable_RandomAccessIteratorConcept<_Iterator> >();
00668       __function_requires<
00669         _Mutable_RandomAccessIteratorConcept<_Reverse_iterator> >();
00670 
00671       _Reference __r _IsUnused = __c[__i];
00672     }
00673     _Size_type __i;
00674     _RandomAccessContainer __c;
00675   };
00676 
00677   // A Sequence is inherently mutable
00678   template <class _Sequence>
00679   struct _SequenceConcept
00680   {
00681     typedef typename _Sequence::reference _Reference;
00682     typedef typename _Sequence::const_reference _Const_reference;
00683 
00684     void __constraints() {
00685       // Matt Austern's book puts DefaultConstructible here, the C++
00686       // standard places it in Container
00687       //    function_requires< DefaultConstructible<Sequence> >();
00688       __function_requires< _Mutable_ForwardContainerConcept<_Sequence> >();
00689       __function_requires< _DefaultConstructibleConcept<_Sequence> >();
00690 
00691       _Sequence 
00692         __c(__n) _IsUnused,
00693         __c2(__n, __t) _IsUnused,
00694         __c3(__first, __last) _IsUnused;
00695 
00696       __c.insert(__p, __t);
00697       __c.insert(__p, __n, __t);
00698       __c.insert(__p, __first, __last);
00699 
00700       __c.erase(__p);
00701       __c.erase(__p, __q);
00702 
00703       _Reference __r _IsUnused = __c.front();
00704 
00705       __const_constraints(__c);
00706     }
00707     void __const_constraints(const _Sequence& __c) {
00708       _Const_reference __r _IsUnused = __c.front();
00709     }
00710     typename _Sequence::value_type __t;
00711     typename _Sequence::size_type __n;
00712     typename _Sequence::value_type *__first, *__last;
00713     typename _Sequence::iterator __p, __q;
00714   };
00715 
00716   template <class _FrontInsertionSequence>
00717   struct _FrontInsertionSequenceConcept
00718   {
00719     void __constraints() {
00720       __function_requires< _SequenceConcept<_FrontInsertionSequence> >();
00721 
00722       __c.push_front(__t);
00723       __c.pop_front();
00724     }
00725     _FrontInsertionSequence __c;
00726     typename _FrontInsertionSequence::value_type __t;
00727   };
00728 
00729   template <class _BackInsertionSequence>
00730   struct _BackInsertionSequenceConcept
00731   {
00732     typedef typename _BackInsertionSequence::reference _Reference;
00733     typedef typename _BackInsertionSequence::const_reference _Const_reference;
00734 
00735     void __constraints() {
00736       __function_requires< _SequenceConcept<_BackInsertionSequence> >();
00737 
00738       __c.push_back(__t);
00739       __c.pop_back();
00740       _Reference __r _IsUnused = __c.back();
00741     }
00742     void __const_constraints(const _BackInsertionSequence& __c) {
00743       _Const_reference __r _IsUnused = __c.back();
00744     };
00745     _BackInsertionSequence __c;
00746     typename _BackInsertionSequence::value_type __t;
00747   };
00748 
00749   template <class _AssociativeContainer>
00750   struct _AssociativeContainerConcept
00751   {
00752     void __constraints() {
00753       __function_requires< _ForwardContainerConcept<_AssociativeContainer> >();
00754       __function_requires<
00755         _DefaultConstructibleConcept<_AssociativeContainer> >();
00756     
00757       __i = __c.find(__k);
00758       __r = __c.equal_range(__k);
00759       __c.erase(__k);
00760       __c.erase(__i);
00761       __c.erase(__r.first, __r.second);
00762       __const_constraints(__c);
00763     }
00764     void __const_constraints(const _AssociativeContainer& __c) {
00765       __ci = __c.find(__k);
00766       __n = __c.count(__k);
00767       __cr = __c.equal_range(__k);
00768     }
00769     typedef typename _AssociativeContainer::iterator _Iterator;
00770     typedef typename _AssociativeContainer::const_iterator _Const_iterator;
00771 
00772     _AssociativeContainer __c;
00773     _Iterator __i;
00774     std::pair<_Iterator,_Iterator> __r;
00775     _Const_iterator __ci;
00776     std::pair<_Const_iterator,_Const_iterator> __cr;
00777     typename _AssociativeContainer::key_type __k;
00778     typename _AssociativeContainer::size_type __n;
00779   };
00780 
00781   template <class _UniqueAssociativeContainer>
00782   struct _UniqueAssociativeContainerConcept
00783   {
00784     void __constraints() {
00785       __function_requires<
00786         _AssociativeContainerConcept<_UniqueAssociativeContainer> >();
00787     
00788       _UniqueAssociativeContainer __c(__first, __last);
00789       
00790       __pos_flag = __c.insert(__t);
00791       __c.insert(__first, __last);
00792     }
00793     std::pair<typename _UniqueAssociativeContainer::iterator, bool> __pos_flag;
00794     typename _UniqueAssociativeContainer::value_type __t;
00795     typename _UniqueAssociativeContainer::value_type *__first, *__last;
00796   };
00797 
00798   template <class _MultipleAssociativeContainer>
00799   struct _MultipleAssociativeContainerConcept
00800   {
00801     void __constraints() {
00802       __function_requires<
00803         _AssociativeContainerConcept<_MultipleAssociativeContainer> >();
00804 
00805       _MultipleAssociativeContainer __c(__first, __last);
00806       
00807       __pos = __c.insert(__t);
00808       __c.insert(__first, __last);
00809 
00810     }
00811     typename _MultipleAssociativeContainer::iterator __pos _IsUnused;
00812     typename _MultipleAssociativeContainer::value_type __t;
00813     typename _MultipleAssociativeContainer::value_type *__first, *__last;
00814   };
00815 
00816   template <class _SimpleAssociativeContainer>
00817   struct _SimpleAssociativeContainerConcept
00818   {
00819     void __constraints() {
00820       __function_requires<
00821         _AssociativeContainerConcept<_SimpleAssociativeContainer> >();
00822       typedef typename _SimpleAssociativeContainer::key_type _Key_type;
00823       typedef typename _SimpleAssociativeContainer::value_type _Value_type;
00824       typedef typename _Aux_require_same<_Key_type, _Value_type>::_Type
00825         _Requqired;
00826     }
00827   };
00828 
00829   template <class _SimpleAssociativeContainer>
00830   struct _PairAssociativeContainerConcept
00831   {
00832     void __constraints() {
00833       __function_requires<
00834         _AssociativeContainerConcept<_SimpleAssociativeContainer> >();
00835       typedef typename _SimpleAssociativeContainer::key_type _Key_type;
00836       typedef typename _SimpleAssociativeContainer::value_type _Value_type;
00837       typedef typename _SimpleAssociativeContainer::mapped_type _Mapped_type;
00838       typedef std::pair<const _Key_type, _Mapped_type> _Required_value_type;
00839       typedef typename _Aux_require_same<_Value_type,
00840         _Required_value_type>::_Type _Required;
00841     }
00842   };
00843 
00844   template <class _SortedAssociativeContainer>
00845   struct _SortedAssociativeContainerConcept
00846   {
00847     void __constraints() {
00848       __function_requires<
00849         _AssociativeContainerConcept<_SortedAssociativeContainer> >();
00850       __function_requires<
00851         _ReversibleContainerConcept<_SortedAssociativeContainer> >();
00852 
00853       _SortedAssociativeContainer 
00854         __c(__kc) _IsUnused,
00855         __c2(__first, __last) _IsUnused,
00856         __c3(__first, __last, __kc) _IsUnused;
00857 
00858       __p = __c.upper_bound(__k);
00859       __p = __c.lower_bound(__k);
00860       __r = __c.equal_range(__k);
00861       
00862       __c.insert(__p, __t);
00863     }
00864     void __const_constraints(const _SortedAssociativeContainer& __c) {
00865       __kc = __c.key_comp();
00866       __vc = __c.value_comp();
00867 
00868       __cp = __c.upper_bound(__k);
00869       __cp = __c.lower_bound(__k);
00870       __cr = __c.equal_range(__k);
00871     }
00872     typename _SortedAssociativeContainer::key_compare __kc;
00873     typename _SortedAssociativeContainer::value_compare __vc;
00874     typename _SortedAssociativeContainer::value_type __t;
00875     typename _SortedAssociativeContainer::key_type __k;
00876     typedef typename _SortedAssociativeContainer::iterator _Iterator;
00877     typedef typename _SortedAssociativeContainer::const_iterator
00878       _Const_iterator;
00879 
00880     _Iterator __p;
00881     _Const_iterator __cp;
00882     std::pair<_Iterator,_Iterator> __r;
00883     std::pair<_Const_iterator,_Const_iterator> __cr;
00884     typename _SortedAssociativeContainer::value_type *__first, *__last;
00885   };
00886 
00887   // HashedAssociativeContainer
00888 
00889 } // namespace __gnu_cxx
00890 
00891 #undef _IsUnused
00892 
00893 #endif // _GLIBCPP_BOOST_CONCEPT_CHECK
00894 
00895 

Generated at Tue May 1 16:28:37 2001 for libstdc++-v3 by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001