home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / stl / sequence_concepts.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-08  |  6.9 KB  |  205 lines

  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 STL_SEQUENCE_CONCEPTS_H
  15. #define STL_SEQUENCE_CONCEPTS_H
  16.  
  17. #include <container_concepts.h>
  18.  
  19. #ifdef __STL_USE_CONCEPT_CHECKS
  20.  
  21. // This file covers the following concepts:
  22. //       _Sequence
  23. //       _FrontInsertionSequence
  24. //       _BackInsertionSequence
  25.  
  26. struct _ERROR_IN_STL_SEQ {
  27.  
  28.   template <class _XX>
  29.   static void
  30.   __fill_constructor_requirement_violation(_XX& __s) {
  31.     typename _XX::value_type __t = typename _XX::value_type();
  32.     typename _XX::difference_type __n = typename _XX::difference_type();
  33.     _XX __x(__n, __t);
  34.     __sink_unused_warning(__x);
  35.   }
  36.   template <class _XX>
  37.   static void
  38.   __fill_default_constructor_requirement_violation(_XX& __s) {
  39.     _STL_ERROR::__default_constructor_requirement_violation(*__s.begin());
  40.     typename _XX::difference_type __n = typename _XX::difference_type();
  41.     _XX __x(__n);
  42.     __sink_unused_warning(__x);
  43.   }  
  44.   template <class _XX>
  45.   static void
  46.   __range_constructor_requirement_violation(_XX& __s) {
  47.     _XX __x(__s.begin(), __s.end());
  48.     __sink_unused_warning(__x);
  49.   }
  50.   template <class _XX>
  51.   static void
  52.   __insert_function_requirement_violation(_XX& __s) {
  53.     typename _XX::value_type __t = typename _XX::value_type();
  54.     typename _XX::iterator __p = typename _XX::iterator();
  55.     __p = __s.insert(__p, __t);
  56.   }
  57.   template <class _XX>
  58.   static void
  59.   __fill_insert_function_requirement_violation(_XX& __s) {
  60.     typename _XX::value_type __t = typename _XX::value_type();
  61.     typename _XX::iterator __p = typename _XX::iterator();
  62.     typename _XX::difference_type __n = typename _XX::difference_type();
  63.     __s.insert(__p, __n, __t);
  64.   }
  65.   template <class _XX>
  66.   static void
  67.   __range_insert_function_requirement_violation(_XX& __s) {
  68.     typename _XX::iterator __p = typename _XX::iterator();
  69.     typename _XX::iterator __i = typename _XX::iterator();
  70.     typename _XX::iterator __j = typename _XX::iterator();
  71.     __s.insert(__p, __i, __j);
  72.   }
  73.   template <class _XX>
  74.   static void
  75.   __insert_element_function_requirement_violation(_XX& __s) {
  76.     typename _XX::value_type __t = typename _XX::value_type();
  77.     std::pair<typename _XX::iterator, bool> __r;
  78.     __r = __s.insert(__t);
  79.     __sink_unused_warning(__r);
  80.   }
  81.   template <class _XX>
  82.   static void
  83.   __unconditional_insert_element_function_requirement_violation(_XX& __s) {
  84.     typename _XX::value_type __t = typename _XX::value_type();
  85.     typename _XX::iterator __p;
  86.     __p = __s.insert(__t);
  87.     __sink_unused_warning(__p);
  88.   }
  89.   template <class _XX>
  90.   static void
  91.   __erase_function_requirement_violation(_XX& __s) {
  92.     typename _XX::iterator __p = typename _XX::iterator();
  93.     __p = __s.erase(__p);
  94.   }
  95.   template <class _XX>
  96.   static void
  97.   __range_erase_function_requirement_violation(_XX& __s) {
  98.     typename _XX::iterator __p = typename _XX::iterator();
  99.     typename _XX::iterator __q = typename _XX::iterator();
  100.     __p = __s.erase(__p, __q);
  101.   }
  102.   template <class _XX>
  103.   static void
  104.   __const_front_function_requirement_violation(const _XX& __s) {
  105.     typename _XX::const_reference __t = __s.front();
  106.     __sink_unused_warning(__t);
  107.   }
  108.   template <class _XX>
  109.   static void
  110.   __front_function_requirement_violation(_XX& __s) {
  111.     typename _XX::reference __t = __s.front();
  112.     __const_front_function_requirement_violation(__s);
  113.     __sink_unused_warning(__t);
  114.   }
  115.   template <class _XX>
  116.   static void
  117.   __const_back_function_requirement_violation(const _XX& __s) {
  118.     typename _XX::const_reference __t = __s.back();
  119.     __sink_unused_warning(__t);
  120.   }
  121.   template <class _XX>
  122.   static void
  123.   __back_function_requirement_violation(_XX& __s) {
  124.     typename _XX::reference __t = __s.back();
  125.     __const_back_function_requirement_violation(__s);
  126.     __sink_unused_warning(__t);
  127.   }
  128.   template <class _XX>
  129.   static void
  130.   __push_front_function_requirement_violation(_XX& __s) {
  131.     typename _XX::value_type __t = typename _XX::value_type();
  132.     __s.push_front(__t);
  133.   }
  134.   template <class _XX>
  135.   static void
  136.   __pop_front_function_requirement_violation(_XX& __s) {
  137.     __s.pop_front();
  138.   }
  139.   template <class _XX>
  140.   static void
  141.   __push_back_function_requirement_violation(_XX& __s) {
  142.     typename _XX::value_type __t = typename _XX::value_type();
  143.     __s.push_back(__t);
  144.   }
  145.   template <class _XX>
  146.   static void
  147.   __pop_back_function_requirement_violation(_XX& __s) {
  148.     __s.pop_back();
  149.   }
  150.  
  151. };
  152.  
  153. /* Sequence Containers */
  154.  
  155. template <class _Sequence>
  156. struct _Sequence_concept_specification {
  157. static void
  158. _Sequence_requirement_violation(_Sequence __s) {
  159.   // Refinement of ForwardContainer
  160.   _ForwardContainer_concept_specification<_Sequence>::_ForwardContainer_requirement_violation(__s);
  161.   // Refinement of DefaultConstructible
  162.   _DefaultConstructible_concept_specification<_Sequence>::_DefaultConstructible_requirement_violation(__s);
  163.   // Valid Expressions
  164.   _ERROR_IN_STL_SEQ::__fill_constructor_requirement_violation(__s);
  165.   _ERROR_IN_STL_SEQ::__fill_default_constructor_requirement_violation(__s);
  166.   _ERROR_IN_STL_SEQ::__range_constructor_requirement_violation(__s);
  167.   _ERROR_IN_STL_SEQ::__insert_function_requirement_violation(__s);
  168.   _ERROR_IN_STL_SEQ::__fill_insert_function_requirement_violation(__s);
  169.   _ERROR_IN_STL_SEQ::__range_insert_function_requirement_violation(__s);
  170.   _ERROR_IN_STL_SEQ::__erase_function_requirement_violation(__s);
  171.   _ERROR_IN_STL_SEQ::__range_erase_function_requirement_violation(__s);
  172.   _ERROR_IN_STL_SEQ::__front_function_requirement_violation(__s);
  173. }
  174. };
  175.  
  176. template <class _FrontInsertionSequence>
  177. struct _FrontInsertionSequence_concept_specification {
  178. static void
  179. _FrontInsertionSequence_requirement_violation(_FrontInsertionSequence __s) {
  180.   // Refinement of Sequence
  181.   _Sequence_concept_specification<_FrontInsertionSequence>::_Sequence_requirement_violation(__s);
  182.   // Valid Expressions
  183.   _ERROR_IN_STL_SEQ::__push_front_function_requirement_violation(__s);
  184.   _ERROR_IN_STL_SEQ::__pop_front_function_requirement_violation(__s);
  185. }
  186. };
  187.  
  188. template <class _BackInsertionSequence>
  189. struct _BackInsertionSequence_concept_specification {
  190. static void
  191. _BackInsertionSequence_requirement_violation(_BackInsertionSequence __s) {
  192.   // Refinement of Sequence
  193.   _Sequence_concept_specification<_BackInsertionSequence>::_Sequence_requirement_violation(__s);
  194.   // Valid Expressions
  195.   _ERROR_IN_STL_SEQ::__back_function_requirement_violation(__s);
  196.   _ERROR_IN_STL_SEQ::__push_back_function_requirement_violation(__s);
  197.   _ERROR_IN_STL_SEQ::__pop_back_function_requirement_violation(__s);
  198. }
  199. };
  200.  
  201. #endif /* if __STL_USE_CONCEPT_CHECKS */
  202.  
  203.  
  204. #endif /* STL_SEQUENCE_CONCEPTS_H */
  205.