Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:34:12

0001 //
0002 // (C) Copyright Jeremy Siek 2000.
0003 // Copyright 2002 The Trustees of Indiana University.
0004 //
0005 // Distributed under the Boost Software License, Version 1.0. (See
0006 // accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // Revision History:
0010 //   05 May   2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek)
0011 //   02 April 2001: Removed limits header altogether. (Jeremy Siek)
0012 //   01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock)
0013 //
0014 
0015 // See http://www.boost.org/libs/concept_check for documentation.
0016 
0017 #ifndef BOOST_CONCEPT_CHECKS_HPP
0018 # define BOOST_CONCEPT_CHECKS_HPP
0019 
0020 # include <boost/concept/assert.hpp>
0021 
0022 # include <iterator>
0023 # include <boost/type_traits/conversion_traits.hpp>
0024 # include <utility>
0025 # include <boost/type_traits/is_same.hpp>
0026 # include <boost/type_traits/is_void.hpp>
0027 # include <boost/static_assert.hpp>
0028 # include <boost/type_traits/integral_constant.hpp>
0029 # include <boost/config/workaround.hpp>
0030 
0031 # include <boost/concept/usage.hpp>
0032 # include <boost/concept/detail/concept_def.hpp>
0033 
0034 #if (defined _MSC_VER)
0035 # pragma warning( push )
0036 # pragma warning( disable : 4510 ) // default constructor could not be generated
0037 # pragma warning( disable : 4610 ) // object 'class' can never be instantiated - user-defined constructor required
0038 #endif
0039 
0040 namespace boost
0041 {
0042 
0043   //
0044   // Backward compatibility
0045   //
0046 
0047   template <class Model>
0048   inline void function_requires(Model* = 0)
0049   {
0050       BOOST_CONCEPT_ASSERT((Model));
0051   }
0052   template <class T> inline void ignore_unused_variable_warning(T const&) {}
0053 
0054 #  define BOOST_CLASS_REQUIRE(type_var, ns, concept)    \
0055     BOOST_CONCEPT_ASSERT((ns::concept<type_var>))
0056 
0057 #  define BOOST_CLASS_REQUIRE2(type_var1, type_var2, ns, concept)   \
0058     BOOST_CONCEPT_ASSERT((ns::concept<type_var1,type_var2>))
0059 
0060 #  define BOOST_CLASS_REQUIRE3(tv1, tv2, tv3, ns, concept)  \
0061     BOOST_CONCEPT_ASSERT((ns::concept<tv1,tv2,tv3>))
0062 
0063 #  define BOOST_CLASS_REQUIRE4(tv1, tv2, tv3, tv4, ns, concept) \
0064     BOOST_CONCEPT_ASSERT((ns::concept<tv1,tv2,tv3,tv4>))
0065 
0066 
0067   //
0068   // Begin concept definitions
0069   //
0070   BOOST_concept(Integer, (T))
0071   {
0072       BOOST_CONCEPT_USAGE(Integer)
0073         {
0074             x.error_type_must_be_an_integer_type();
0075         }
0076    private:
0077       T x;
0078   };
0079 
0080   template <> struct Integer<char> {};
0081   template <> struct Integer<signed char> {};
0082   template <> struct Integer<unsigned char> {};
0083   template <> struct Integer<short> {};
0084   template <> struct Integer<unsigned short> {};
0085   template <> struct Integer<int> {};
0086   template <> struct Integer<unsigned int> {};
0087   template <> struct Integer<long> {};
0088   template <> struct Integer<unsigned long> {};
0089 # if defined(BOOST_HAS_LONG_LONG)
0090   template <> struct Integer< ::boost::long_long_type> {};
0091   template <> struct Integer< ::boost::ulong_long_type> {};
0092 # elif defined(BOOST_HAS_MS_INT64)
0093   template <> struct Integer<__int64> {};
0094   template <> struct Integer<unsigned __int64> {};
0095 # endif
0096 
0097   BOOST_concept(SignedInteger,(T)) {
0098     BOOST_CONCEPT_USAGE(SignedInteger) {
0099       x.error_type_must_be_a_signed_integer_type();
0100     }
0101    private:
0102     T x;
0103   };
0104   template <> struct SignedInteger<signed char> { };
0105   template <> struct SignedInteger<short> {};
0106   template <> struct SignedInteger<int> {};
0107   template <> struct SignedInteger<long> {};
0108 # if defined(BOOST_HAS_LONG_LONG)
0109   template <> struct SignedInteger< ::boost::long_long_type> {};
0110 # elif defined(BOOST_HAS_MS_INT64)
0111   template <> struct SignedInteger<__int64> {};
0112 # endif
0113 
0114   BOOST_concept(UnsignedInteger,(T)) {
0115     BOOST_CONCEPT_USAGE(UnsignedInteger) {
0116       x.error_type_must_be_an_unsigned_integer_type();
0117     }
0118    private:
0119     T x;
0120   };
0121 
0122   template <> struct UnsignedInteger<unsigned char> {};
0123   template <> struct UnsignedInteger<unsigned short> {};
0124   template <> struct UnsignedInteger<unsigned int> {};
0125   template <> struct UnsignedInteger<unsigned long> {};
0126 # if defined(BOOST_HAS_LONG_LONG)
0127   template <> struct UnsignedInteger< ::boost::ulong_long_type> {};
0128 # elif defined(BOOST_HAS_MS_INT64)
0129   template <> struct UnsignedInteger<unsigned __int64> {};
0130 # endif
0131 
0132   //===========================================================================
0133   // Basic Concepts
0134 
0135   BOOST_concept(DefaultConstructible,(TT))
0136   {
0137     BOOST_CONCEPT_USAGE(DefaultConstructible) {
0138       TT a;               // require default constructor
0139       ignore_unused_variable_warning(a);
0140     }
0141   };
0142 
0143   BOOST_concept(Assignable,(TT))
0144   {
0145     BOOST_CONCEPT_USAGE(Assignable) {
0146 #if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL
0147       a = b;             // require assignment operator
0148 #endif
0149       const_constraints(b);
0150     }
0151    private:
0152     void const_constraints(const TT& x) {
0153 #if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL
0154       a = x;              // const required for argument to assignment
0155 #else
0156       ignore_unused_variable_warning(x);
0157 #endif
0158     }
0159    private:
0160     TT a;
0161     TT b;
0162   };
0163 
0164 
0165   BOOST_concept(CopyConstructible,(TT))
0166   {
0167     BOOST_CONCEPT_USAGE(CopyConstructible) {
0168       TT a(b);            // require copy constructor
0169       TT* ptr = &a;       // require address of operator
0170       const_constraints(a);
0171       ignore_unused_variable_warning(ptr);
0172     }
0173    private:
0174     void const_constraints(const TT& a) {
0175       TT c(a);            // require const copy constructor
0176       const TT* ptr = &a; // require const address of operator
0177       ignore_unused_variable_warning(c);
0178       ignore_unused_variable_warning(ptr);
0179     }
0180     TT b;
0181   };
0182 
0183   // The SGI STL version of Assignable requires copy constructor and operator=
0184   BOOST_concept(SGIAssignable,(TT))
0185   {
0186     BOOST_CONCEPT_USAGE(SGIAssignable) {
0187       TT c(a);
0188 #if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL
0189       a = b;              // require assignment operator
0190 #endif
0191       const_constraints(b);
0192       ignore_unused_variable_warning(c);
0193     }
0194    private:
0195     void const_constraints(const TT& x) {
0196       TT c(x);
0197 #if !defined(_ITERATOR_) // back_insert_iterator broken for VC++ STL
0198       a = x;              // const required for argument to assignment
0199 #endif
0200       ignore_unused_variable_warning(c);
0201     }
0202     TT a;
0203     TT b;
0204   };
0205 
0206   BOOST_concept(Convertible,(X)(Y))
0207   {
0208     BOOST_CONCEPT_USAGE(Convertible) {
0209       Y y = x;
0210       ignore_unused_variable_warning(y);
0211     }
0212    private:
0213     X x;
0214   };
0215 
0216   // The C++ standard requirements for many concepts talk about return
0217   // types that must be "convertible to bool".  The problem with this
0218   // requirement is that it leaves the door open for evil proxies that
0219   // define things like operator|| with strange return types.  Two
0220   // possible solutions are:
0221   // 1) require the return type to be exactly bool
0222   // 2) stay with convertible to bool, and also
0223   //    specify stuff about all the logical operators.
0224   // For now we just test for convertible to bool.
0225   template <class TT>
0226   void require_boolean_expr(const TT& t) {
0227     bool x = t;
0228     ignore_unused_variable_warning(x);
0229   }
0230 
0231   BOOST_concept(EqualityComparable,(TT))
0232   {
0233     BOOST_CONCEPT_USAGE(EqualityComparable) {
0234       require_boolean_expr(a == b);
0235       require_boolean_expr(a != b);
0236     }
0237    private:
0238     TT a, b;
0239   };
0240 
0241   BOOST_concept(LessThanComparable,(TT))
0242   {
0243     BOOST_CONCEPT_USAGE(LessThanComparable) {
0244       require_boolean_expr(a < b);
0245     }
0246    private:
0247     TT a, b;
0248   };
0249 
0250   // This is equivalent to SGI STL's LessThanComparable.
0251   BOOST_concept(Comparable,(TT))
0252   {
0253     BOOST_CONCEPT_USAGE(Comparable) {
0254       require_boolean_expr(a < b);
0255       require_boolean_expr(a > b);
0256       require_boolean_expr(a <= b);
0257       require_boolean_expr(a >= b);
0258     }
0259    private:
0260     TT a, b;
0261   };
0262 
0263 #define BOOST_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(OP,NAME)    \
0264   BOOST_concept(NAME, (First)(Second))                          \
0265   {                                                             \
0266       BOOST_CONCEPT_USAGE(NAME) { (void)constraints_(); }                         \
0267      private:                                                   \
0268         bool constraints_() { return a OP b; }                  \
0269         First a;                                                \
0270         Second b;                                               \
0271   }
0272 
0273 #define BOOST_DEFINE_BINARY_OPERATOR_CONSTRAINT(OP,NAME)    \
0274   BOOST_concept(NAME, (Ret)(First)(Second))                 \
0275   {                                                         \
0276       BOOST_CONCEPT_USAGE(NAME) { (void)constraints_(); }                     \
0277   private:                                                  \
0278       Ret constraints_() { return a OP b; }                 \
0279       First a;                                              \
0280       Second b;                                             \
0281   }
0282 
0283   BOOST_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(==, EqualOp);
0284   BOOST_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(!=, NotEqualOp);
0285   BOOST_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<, LessThanOp);
0286   BOOST_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<=, LessEqualOp);
0287   BOOST_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>, GreaterThanOp);
0288   BOOST_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>=, GreaterEqualOp);
0289 
0290   BOOST_DEFINE_BINARY_OPERATOR_CONSTRAINT(+, PlusOp);
0291   BOOST_DEFINE_BINARY_OPERATOR_CONSTRAINT(*, TimesOp);
0292   BOOST_DEFINE_BINARY_OPERATOR_CONSTRAINT(/, DivideOp);
0293   BOOST_DEFINE_BINARY_OPERATOR_CONSTRAINT(-, SubtractOp);
0294   BOOST_DEFINE_BINARY_OPERATOR_CONSTRAINT(%, ModOp);
0295 
0296   //===========================================================================
0297   // Function Object Concepts
0298 
0299   BOOST_concept(Generator,(Func)(Return))
0300   {
0301       BOOST_CONCEPT_USAGE(Generator) { test(is_void<Return>()); }
0302 
0303    private:
0304       void test(boost::false_type)
0305       {
0306           // Do we really want a reference here?
0307           const Return& r = f();
0308           ignore_unused_variable_warning(r);
0309       }
0310 
0311       void test(boost::true_type)
0312       {
0313           f();
0314       }
0315 
0316       Func f;
0317   };
0318 
0319   BOOST_concept(UnaryFunction,(Func)(Return)(Arg))
0320   {
0321       BOOST_CONCEPT_USAGE(UnaryFunction) { test(is_void<Return>()); }
0322 
0323    private:
0324       void test(boost::false_type)
0325       {
0326           f(arg);               // "priming the pump" this way keeps msvc6 happy (ICE)
0327           Return r = f(arg);
0328           ignore_unused_variable_warning(r);
0329       }
0330 
0331       void test(boost::true_type)
0332       {
0333           f(arg);
0334       }
0335 
0336 #if (BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(4) \
0337                       && BOOST_WORKAROUND(__GNUC__, > 3)))
0338       // Declare a dummy constructor to make gcc happy.
0339       // It seems the compiler can not generate a sensible constructor when this is instantiated with a reference type.
0340       // (warning: non-static reference "const double& boost::UnaryFunction<YourClassHere>::arg"
0341       // in class without a constructor [-Wuninitialized])
0342       UnaryFunction();
0343 #endif
0344 
0345       Func f;
0346       Arg arg;
0347   };
0348 
0349   BOOST_concept(BinaryFunction,(Func)(Return)(First)(Second))
0350   {
0351       BOOST_CONCEPT_USAGE(BinaryFunction) { test(is_void<Return>()); }
0352    private:
0353       void test(boost::false_type)
0354       {
0355           (void) f(first,second);
0356           Return r = f(first, second); // require operator()
0357           (void)r;
0358       }
0359 
0360       void test(boost::true_type)
0361       {
0362           f(first,second);
0363       }
0364 
0365 #if (BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(4) \
0366                       && BOOST_WORKAROUND(__GNUC__, > 3)))
0367       // Declare a dummy constructor to make gcc happy.
0368       // It seems the compiler can not generate a sensible constructor when this is instantiated with a reference type.
0369       // (warning: non-static reference "const double& boost::BinaryFunction<YourClassHere>::arg"
0370       // in class without a constructor [-Wuninitialized])
0371       BinaryFunction();
0372 #endif
0373 
0374       Func f;
0375       First first;
0376       Second second;
0377   };
0378 
0379   BOOST_concept(UnaryPredicate,(Func)(Arg))
0380   {
0381     BOOST_CONCEPT_USAGE(UnaryPredicate) {
0382       require_boolean_expr(f(arg)); // require operator() returning bool
0383     }
0384    private:
0385 #if (BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(4) \
0386                       && BOOST_WORKAROUND(__GNUC__, > 3)))
0387       // Declare a dummy constructor to make gcc happy.
0388       // It seems the compiler can not generate a sensible constructor when this is instantiated with a reference type.
0389       // (warning: non-static reference "const double& boost::UnaryPredicate<YourClassHere>::arg"
0390       // in class without a constructor [-Wuninitialized])
0391       UnaryPredicate();
0392 #endif
0393 
0394     Func f;
0395     Arg arg;
0396   };
0397 
0398   BOOST_concept(BinaryPredicate,(Func)(First)(Second))
0399   {
0400     BOOST_CONCEPT_USAGE(BinaryPredicate) {
0401       require_boolean_expr(f(a, b)); // require operator() returning bool
0402     }
0403    private:
0404 #if (BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(4) \
0405                       && BOOST_WORKAROUND(__GNUC__, > 3)))
0406       // Declare a dummy constructor to make gcc happy.
0407       // It seems the compiler can not generate a sensible constructor when this is instantiated with a reference type.
0408       // (warning: non-static reference "const double& boost::BinaryPredicate<YourClassHere>::arg"
0409       // in class without a constructor [-Wuninitialized])
0410       BinaryPredicate();
0411 #endif
0412     Func f;
0413     First a;
0414     Second b;
0415   };
0416 
0417   // use this when functor is used inside a container class like std::set
0418   BOOST_concept(Const_BinaryPredicate,(Func)(First)(Second))
0419     : BinaryPredicate<Func, First, Second>
0420   {
0421     BOOST_CONCEPT_USAGE(Const_BinaryPredicate) {
0422       const_constraints(f);
0423     }
0424    private:
0425     void const_constraints(const Func& fun) {
0426       // operator() must be a const member function
0427       require_boolean_expr(fun(a, b));
0428     }
0429 #if (BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(4) \
0430                       && BOOST_WORKAROUND(__GNUC__, > 3)))
0431       // Declare a dummy constructor to make gcc happy.
0432       // It seems the compiler can not generate a sensible constructor when this is instantiated with a reference type.
0433       // (warning: non-static reference "const double& boost::Const_BinaryPredicate<YourClassHere>::arg"
0434       // in class without a constructor [-Wuninitialized])
0435       Const_BinaryPredicate();
0436 #endif
0437 
0438     Func f;
0439     First a;
0440     Second b;
0441   };
0442 
0443   BOOST_concept(AdaptableGenerator,(Func)(Return))
0444     : Generator<Func, typename Func::result_type>
0445   {
0446       typedef typename Func::result_type result_type;
0447 
0448       BOOST_CONCEPT_USAGE(AdaptableGenerator)
0449       {
0450           BOOST_CONCEPT_ASSERT((Convertible<result_type, Return>));
0451       }
0452   };
0453 
0454   BOOST_concept(AdaptableUnaryFunction,(Func)(Return)(Arg))
0455     : UnaryFunction<Func, typename Func::result_type, typename Func::argument_type>
0456   {
0457       typedef typename Func::argument_type argument_type;
0458       typedef typename Func::result_type result_type;
0459 
0460       ~AdaptableUnaryFunction()
0461       {
0462           BOOST_CONCEPT_ASSERT((Convertible<result_type, Return>));
0463           BOOST_CONCEPT_ASSERT((Convertible<Arg, argument_type>));
0464       }
0465   };
0466 
0467   BOOST_concept(AdaptableBinaryFunction,(Func)(Return)(First)(Second))
0468     : BinaryFunction<
0469           Func
0470         , typename Func::result_type
0471         , typename Func::first_argument_type
0472         , typename Func::second_argument_type
0473       >
0474   {
0475       typedef typename Func::first_argument_type first_argument_type;
0476       typedef typename Func::second_argument_type second_argument_type;
0477       typedef typename Func::result_type result_type;
0478 
0479       ~AdaptableBinaryFunction()
0480       {
0481           BOOST_CONCEPT_ASSERT((Convertible<result_type, Return>));
0482           BOOST_CONCEPT_ASSERT((Convertible<First, first_argument_type>));
0483           BOOST_CONCEPT_ASSERT((Convertible<Second, second_argument_type>));
0484       }
0485   };
0486 
0487   BOOST_concept(AdaptablePredicate,(Func)(Arg))
0488     : UnaryPredicate<Func, Arg>
0489     , AdaptableUnaryFunction<Func, bool, Arg>
0490   {
0491   };
0492 
0493   BOOST_concept(AdaptableBinaryPredicate,(Func)(First)(Second))
0494     : BinaryPredicate<Func, First, Second>
0495     , AdaptableBinaryFunction<Func, bool, First, Second>
0496   {
0497   };
0498 
0499   //===========================================================================
0500   // Iterator Concepts
0501 
0502   BOOST_concept(InputIterator,(TT))
0503     : Assignable<TT>
0504     , EqualityComparable<TT>
0505   {
0506       typedef typename std::iterator_traits<TT>::value_type value_type;
0507       typedef typename std::iterator_traits<TT>::difference_type difference_type;
0508       typedef typename std::iterator_traits<TT>::reference reference;
0509       typedef typename std::iterator_traits<TT>::pointer pointer;
0510       typedef typename std::iterator_traits<TT>::iterator_category iterator_category;
0511 
0512       BOOST_CONCEPT_USAGE(InputIterator)
0513       {
0514         BOOST_CONCEPT_ASSERT((SignedInteger<difference_type>));
0515         BOOST_CONCEPT_ASSERT((Convertible<iterator_category, std::input_iterator_tag>));
0516 
0517         TT j(i);
0518         (void)*i;           // require dereference operator
0519         ++j;                // require preincrement operator
0520         i++;                // require postincrement operator
0521       }
0522    private:
0523     TT i;
0524   };
0525 
0526   BOOST_concept(OutputIterator,(TT)(ValueT))
0527     : Assignable<TT>
0528   {
0529     BOOST_CONCEPT_USAGE(OutputIterator) {
0530 
0531       ++i;                // require preincrement operator
0532       i++;                // require postincrement operator
0533       *i++ = t;           // require postincrement and assignment
0534     }
0535    private:
0536     TT i, j;
0537     ValueT t;
0538   };
0539 
0540   BOOST_concept(ForwardIterator,(TT))
0541     : InputIterator<TT>
0542   {
0543       BOOST_CONCEPT_USAGE(ForwardIterator)
0544       {
0545           BOOST_CONCEPT_ASSERT((Convertible<
0546               BOOST_DEDUCED_TYPENAME ForwardIterator::iterator_category
0547             , std::forward_iterator_tag
0548           >));
0549 
0550           typename InputIterator<TT>::reference r = *i;
0551           ignore_unused_variable_warning(r);
0552       }
0553 
0554    private:
0555       TT i;
0556   };
0557 
0558   BOOST_concept(Mutable_ForwardIterator,(TT))
0559     : ForwardIterator<TT>
0560   {
0561       BOOST_CONCEPT_USAGE(Mutable_ForwardIterator) {
0562         *i++ = *j;         // require postincrement and assignment
0563       }
0564    private:
0565       TT i, j;
0566   };
0567 
0568   BOOST_concept(BidirectionalIterator,(TT))
0569     : ForwardIterator<TT>
0570   {
0571       BOOST_CONCEPT_USAGE(BidirectionalIterator)
0572       {
0573           BOOST_CONCEPT_ASSERT((Convertible<
0574               BOOST_DEDUCED_TYPENAME BidirectionalIterator::iterator_category
0575             , std::bidirectional_iterator_tag
0576           >));
0577 
0578           --i;                // require predecrement operator
0579           i--;                // require postdecrement operator
0580       }
0581    private:
0582       TT i;
0583   };
0584 
0585   BOOST_concept(Mutable_BidirectionalIterator,(TT))
0586     : BidirectionalIterator<TT>
0587     , Mutable_ForwardIterator<TT>
0588   {
0589       BOOST_CONCEPT_USAGE(Mutable_BidirectionalIterator)
0590       {
0591           *i-- = *j;                  // require postdecrement and assignment
0592       }
0593    private:
0594       TT i, j;
0595   };
0596 
0597   BOOST_concept(RandomAccessIterator,(TT))
0598     : BidirectionalIterator<TT>
0599     , Comparable<TT>
0600   {
0601       BOOST_CONCEPT_USAGE(RandomAccessIterator)
0602       {
0603           BOOST_CONCEPT_ASSERT((Convertible<
0604               BOOST_DEDUCED_TYPENAME BidirectionalIterator<TT>::iterator_category
0605             , std::random_access_iterator_tag
0606           >));
0607 
0608           i += n;             // require assignment addition operator
0609           i = i + n; i = n + i; // require addition with difference type
0610           i -= n;             // require assignment subtraction operator
0611           i = i - n;                  // require subtraction with difference type
0612           n = i - j;                  // require difference operator
0613           (void)i[n];                 // require element access operator
0614       }
0615 
0616    private:
0617     TT a, b;
0618     TT i, j;
0619       typename std::iterator_traits<TT>::difference_type n;
0620   };
0621 
0622   BOOST_concept(Mutable_RandomAccessIterator,(TT))
0623     : RandomAccessIterator<TT>
0624     , Mutable_BidirectionalIterator<TT>
0625   {
0626       BOOST_CONCEPT_USAGE(Mutable_RandomAccessIterator)
0627       {
0628           i[n] = *i;                  // require element access and assignment
0629       }
0630    private:
0631     TT i;
0632     typename std::iterator_traits<TT>::difference_type n;
0633   };
0634 
0635   //===========================================================================
0636   // Container s
0637 
0638   BOOST_concept(Container,(C))
0639     : Assignable<C>
0640   {
0641     typedef typename C::value_type value_type;
0642     typedef typename C::difference_type difference_type;
0643     typedef typename C::size_type size_type;
0644     typedef typename C::const_reference const_reference;
0645     typedef typename C::const_pointer const_pointer;
0646     typedef typename C::const_iterator const_iterator;
0647 
0648       BOOST_CONCEPT_USAGE(Container)
0649       {
0650           BOOST_CONCEPT_ASSERT((InputIterator<const_iterator>));
0651           const_constraints(c);
0652       }
0653 
0654    private:
0655       void const_constraints(const C& cc) {
0656           i = cc.begin();
0657           i = cc.end();
0658           n = cc.size();
0659           n = cc.max_size();
0660           b = cc.empty();
0661       }
0662       C c;
0663       bool b;
0664       const_iterator i;
0665       size_type n;
0666   };
0667 
0668   BOOST_concept(Mutable_Container,(C))
0669     : Container<C>
0670   {
0671       typedef typename C::reference reference;
0672       typedef typename C::iterator iterator;
0673       typedef typename C::pointer pointer;
0674 
0675       BOOST_CONCEPT_USAGE(Mutable_Container)
0676       {
0677           BOOST_CONCEPT_ASSERT((
0678                Assignable<typename Mutable_Container::value_type>));
0679 
0680           BOOST_CONCEPT_ASSERT((InputIterator<iterator>));
0681 
0682           i = c.begin();
0683           i = c.end();
0684           c.swap(c2);
0685       }
0686 
0687    private:
0688       iterator i;
0689       C c, c2;
0690   };
0691 
0692   BOOST_concept(ForwardContainer,(C))
0693     : Container<C>
0694   {
0695       BOOST_CONCEPT_USAGE(ForwardContainer)
0696       {
0697           BOOST_CONCEPT_ASSERT((
0698                ForwardIterator<
0699                     typename ForwardContainer::const_iterator
0700                >));
0701       }
0702   };
0703 
0704   BOOST_concept(Mutable_ForwardContainer,(C))
0705     : ForwardContainer<C>
0706     , Mutable_Container<C>
0707   {
0708       BOOST_CONCEPT_USAGE(Mutable_ForwardContainer)
0709       {
0710           BOOST_CONCEPT_ASSERT((
0711                Mutable_ForwardIterator<
0712                    typename Mutable_ForwardContainer::iterator
0713                >));
0714       }
0715   };
0716 
0717   BOOST_concept(ReversibleContainer,(C))
0718     : ForwardContainer<C>
0719   {
0720       typedef typename
0721         C::const_reverse_iterator
0722       const_reverse_iterator;
0723 
0724       BOOST_CONCEPT_USAGE(ReversibleContainer)
0725       {
0726           BOOST_CONCEPT_ASSERT((
0727               BidirectionalIterator<
0728                   typename ReversibleContainer::const_iterator>));
0729 
0730           BOOST_CONCEPT_ASSERT((BidirectionalIterator<const_reverse_iterator>));
0731 
0732           const_constraints(c);
0733       }
0734    private:
0735       void const_constraints(const C& cc)
0736       {
0737           const_reverse_iterator _i = cc.rbegin();
0738           _i = cc.rend();
0739       }
0740       C c;
0741   };
0742 
0743   BOOST_concept(Mutable_ReversibleContainer,(C))
0744     : Mutable_ForwardContainer<C>
0745     , ReversibleContainer<C>
0746   {
0747       typedef typename C::reverse_iterator reverse_iterator;
0748 
0749       BOOST_CONCEPT_USAGE(Mutable_ReversibleContainer)
0750       {
0751           typedef typename Mutable_ForwardContainer<C>::iterator iterator;
0752           BOOST_CONCEPT_ASSERT((Mutable_BidirectionalIterator<iterator>));
0753           BOOST_CONCEPT_ASSERT((Mutable_BidirectionalIterator<reverse_iterator>));
0754 
0755           reverse_iterator i = c.rbegin();
0756           i = c.rend();
0757       }
0758    private:
0759       C c;
0760   };
0761 
0762   BOOST_concept(RandomAccessContainer,(C))
0763     : ReversibleContainer<C>
0764   {
0765       typedef typename C::size_type size_type;
0766       typedef typename C::const_reference const_reference;
0767 
0768       BOOST_CONCEPT_USAGE(RandomAccessContainer)
0769       {
0770           BOOST_CONCEPT_ASSERT((
0771               RandomAccessIterator<
0772                   typename RandomAccessContainer::const_iterator
0773               >));
0774 
0775           const_constraints(c);
0776       }
0777    private:
0778       void const_constraints(const C& cc)
0779       {
0780           const_reference r = cc[n];
0781           ignore_unused_variable_warning(r);
0782       }
0783 
0784       C c;
0785       size_type n;
0786   };
0787 
0788   BOOST_concept(Mutable_RandomAccessContainer,(C))
0789     : Mutable_ReversibleContainer<C>
0790     , RandomAccessContainer<C>
0791   {
0792    private:
0793       typedef Mutable_RandomAccessContainer self;
0794    public:
0795       BOOST_CONCEPT_USAGE(Mutable_RandomAccessContainer)
0796       {
0797           BOOST_CONCEPT_ASSERT((Mutable_RandomAccessIterator<typename self::iterator>));
0798           BOOST_CONCEPT_ASSERT((Mutable_RandomAccessIterator<typename self::reverse_iterator>));
0799 
0800           typename self::reference r = c[i];
0801           ignore_unused_variable_warning(r);
0802       }
0803 
0804    private:
0805       typename Mutable_ReversibleContainer<C>::size_type i;
0806       C c;
0807   };
0808 
0809   // A Sequence is inherently mutable
0810   BOOST_concept(Sequence,(S))
0811     : Mutable_ForwardContainer<S>
0812       // Matt Austern's book puts DefaultConstructible here, the C++
0813       // standard places it in Container --JGS
0814       // ... so why aren't we following the standard?  --DWA
0815     , DefaultConstructible<S>
0816   {
0817       BOOST_CONCEPT_USAGE(Sequence)
0818       {
0819           S
0820               c(n, t),
0821               c2(first, last);
0822 
0823           c.insert(p, t);
0824           c.insert(p, n, t);
0825           c.insert(p, first, last);
0826 
0827           c.erase(p);
0828           c.erase(p, q);
0829 
0830           typename Sequence::reference r = c.front();
0831 
0832           ignore_unused_variable_warning(c);
0833           ignore_unused_variable_warning(c2);
0834           ignore_unused_variable_warning(r);
0835           const_constraints(c);
0836       }
0837    private:
0838       void const_constraints(const S& c) {
0839           typename Sequence::const_reference r = c.front();
0840           ignore_unused_variable_warning(r);
0841       }
0842 
0843       typename S::value_type t;
0844       typename S::size_type n;
0845       typename S::value_type* first, *last;
0846       typename S::iterator p, q;
0847   };
0848 
0849   BOOST_concept(FrontInsertionSequence,(S))
0850     : Sequence<S>
0851   {
0852       BOOST_CONCEPT_USAGE(FrontInsertionSequence)
0853       {
0854           c.push_front(t);
0855           c.pop_front();
0856       }
0857    private:
0858       S c;
0859       typename S::value_type t;
0860   };
0861 
0862   BOOST_concept(BackInsertionSequence,(S))
0863     : Sequence<S>
0864   {
0865       BOOST_CONCEPT_USAGE(BackInsertionSequence)
0866       {
0867           c.push_back(t);
0868           c.pop_back();
0869           typename BackInsertionSequence::reference r = c.back();
0870           ignore_unused_variable_warning(r);
0871           const_constraints(c);
0872       }
0873    private:
0874       void const_constraints(const S& cc) {
0875           typename BackInsertionSequence::const_reference
0876               r = cc.back();
0877           ignore_unused_variable_warning(r);
0878       }
0879       S c;
0880       typename S::value_type t;
0881   };
0882 
0883   BOOST_concept(AssociativeContainer,(C))
0884     : ForwardContainer<C>
0885     , DefaultConstructible<C>
0886   {
0887       typedef typename C::key_type key_type;
0888       typedef typename C::key_compare key_compare;
0889       typedef typename C::value_compare value_compare;
0890       typedef typename C::iterator iterator;
0891 
0892       BOOST_CONCEPT_USAGE(AssociativeContainer)
0893       {
0894           i = c.find(k);
0895           r = c.equal_range(k);
0896           c.erase(k);
0897           c.erase(i);
0898           c.erase(r.first, r.second);
0899           const_constraints(c);
0900           BOOST_CONCEPT_ASSERT((BinaryPredicate<key_compare,key_type,key_type>));
0901 
0902           typedef typename AssociativeContainer::value_type value_type_;
0903           BOOST_CONCEPT_ASSERT((BinaryPredicate<value_compare,value_type_,value_type_>));
0904       }
0905 
0906       // Redundant with the base concept, but it helps below.
0907       typedef typename C::const_iterator const_iterator;
0908    private:
0909       void const_constraints(const C& cc)
0910       {
0911           ci = cc.find(k);
0912           n = cc.count(k);
0913           cr = cc.equal_range(k);
0914       }
0915 
0916       C c;
0917       iterator i;
0918       std::pair<iterator,iterator> r;
0919       const_iterator ci;
0920       std::pair<const_iterator,const_iterator> cr;
0921       typename C::key_type k;
0922       typename C::size_type n;
0923   };
0924 
0925   BOOST_concept(UniqueAssociativeContainer,(C))
0926     : AssociativeContainer<C>
0927   {
0928       BOOST_CONCEPT_USAGE(UniqueAssociativeContainer)
0929       {
0930           C c(first, last);
0931 
0932           pos_flag = c.insert(t);
0933           c.insert(first, last);
0934 
0935           ignore_unused_variable_warning(c);
0936       }
0937    private:
0938       std::pair<typename C::iterator, bool> pos_flag;
0939       typename C::value_type t;
0940       typename C::value_type* first, *last;
0941   };
0942 
0943   BOOST_concept(MultipleAssociativeContainer,(C))
0944     : AssociativeContainer<C>
0945   {
0946       BOOST_CONCEPT_USAGE(MultipleAssociativeContainer)
0947       {
0948           C c(first, last);
0949 
0950           pos = c.insert(t);
0951           c.insert(first, last);
0952 
0953           ignore_unused_variable_warning(c);
0954           ignore_unused_variable_warning(pos);
0955       }
0956    private:
0957       typename C::iterator pos;
0958       typename C::value_type t;
0959       typename C::value_type* first, *last;
0960   };
0961 
0962   BOOST_concept(SimpleAssociativeContainer,(C))
0963     : AssociativeContainer<C>
0964   {
0965       BOOST_CONCEPT_USAGE(SimpleAssociativeContainer)
0966       {
0967           typedef typename C::key_type key_type;
0968           typedef typename C::value_type value_type;
0969           BOOST_STATIC_ASSERT((boost::is_same<key_type,value_type>::value));
0970       }
0971   };
0972 
0973   BOOST_concept(PairAssociativeContainer,(C))
0974     : AssociativeContainer<C>
0975   {
0976       BOOST_CONCEPT_USAGE(PairAssociativeContainer)
0977       {
0978           typedef typename C::key_type key_type;
0979           typedef typename C::value_type value_type;
0980           typedef typename C::mapped_type mapped_type;
0981           typedef std::pair<const key_type, mapped_type> required_value_type;
0982           BOOST_STATIC_ASSERT((boost::is_same<value_type,required_value_type>::value));
0983       }
0984   };
0985 
0986   BOOST_concept(SortedAssociativeContainer,(C))
0987     : AssociativeContainer<C>
0988     , ReversibleContainer<C>
0989   {
0990       BOOST_CONCEPT_USAGE(SortedAssociativeContainer)
0991       {
0992           C
0993               c(kc),
0994               c2(first, last),
0995               c3(first, last, kc);
0996 
0997           p = c.upper_bound(k);
0998           p = c.lower_bound(k);
0999           r = c.equal_range(k);
1000 
1001           c.insert(p, t);
1002 
1003           ignore_unused_variable_warning(c);
1004           ignore_unused_variable_warning(c2);
1005           ignore_unused_variable_warning(c3);
1006           const_constraints(c);
1007       }
1008 
1009       void const_constraints(const C& c)
1010       {
1011           kc = c.key_comp();
1012           vc = c.value_comp();
1013 
1014           cp = c.upper_bound(k);
1015           cp = c.lower_bound(k);
1016           cr = c.equal_range(k);
1017       }
1018 
1019    private:
1020       typename C::key_compare kc;
1021       typename C::value_compare vc;
1022       typename C::value_type t;
1023       typename C::key_type k;
1024       typedef typename C::iterator iterator;
1025       typedef typename C::const_iterator const_iterator;
1026 
1027       typedef SortedAssociativeContainer self;
1028       iterator p;
1029       const_iterator cp;
1030       std::pair<typename self::iterator,typename self::iterator> r;
1031       std::pair<typename self::const_iterator,typename self::const_iterator> cr;
1032       typename C::value_type* first, *last;
1033   };
1034 
1035   // HashedAssociativeContainer
1036 
1037   BOOST_concept(Collection,(C))
1038   {
1039       BOOST_CONCEPT_USAGE(Collection)
1040       {
1041         boost::function_requires<boost::InputIteratorConcept<iterator> >();
1042         boost::function_requires<boost::InputIteratorConcept<const_iterator> >();
1043         boost::function_requires<boost::CopyConstructibleConcept<value_type> >();
1044         const_constraints(c);
1045         i = c.begin();
1046         i = c.end();
1047         c.swap(c);
1048       }
1049 
1050       void const_constraints(const C& cc) {
1051         ci = cc.begin();
1052         ci = cc.end();
1053         n = cc.size();
1054         b = cc.empty();
1055       }
1056 
1057     private:
1058       typedef typename C::value_type value_type;
1059       typedef typename C::iterator iterator;
1060       typedef typename C::const_iterator const_iterator;
1061       typedef typename C::reference reference;
1062       typedef typename C::const_reference const_reference;
1063       // typedef typename C::pointer pointer;
1064       typedef typename C::difference_type difference_type;
1065       typedef typename C::size_type size_type;
1066 
1067       C c;
1068       bool b;
1069       iterator i;
1070       const_iterator ci;
1071       size_type n;
1072   };
1073 } // namespace boost
1074 
1075 #if (defined _MSC_VER)
1076 # pragma warning( pop )
1077 #endif
1078 
1079 # include <boost/concept/detail/concept_undef.hpp>
1080 
1081 #endif // BOOST_CONCEPT_CHECKS_HPP
1082