]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/concept_check.hpp
simplify Lexer use a bit
[lyx.git] / boost / boost / concept_check.hpp
index decd41316609ba73422f322cfaa4e9674fa3f099..8b090d0232cbf3830ce355fc03ed29efbbd4a57d 100644 (file)
@@ -1,15 +1,17 @@
 //
-// (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify,
-// sell and distribute this software is granted provided this
-// copyright notice appears in all copies. This software is provided
-// "as is" without express or implied warranty, and with no claim as
-// to its suitability for any purpose.
+// (C) Copyright Jeremy Siek 2000.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
 //
 // Revision History:
 //   05 May   2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek)
 //   02 April 2001: Removed limits header altogether. (Jeremy Siek)
 //   01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock)
 //
+
+// See http://www.boost.org/libs/concept_check for documentation.
+
 #ifndef BOOST_CONCEPT_CHECKS_HPP
 #define BOOST_CONCEPT_CHECKS_HPP
 
@@ -19,7 +21,7 @@
 #include <utility>
 #include <boost/type_traits/conversion_traits.hpp>
 #include <boost/static_assert.hpp>
-#include <boost/type.hpp>
+#include <boost/mpl/identity.hpp>
 
 
 #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 || defined(__BORLANDC__)
@@ -40,7 +42,7 @@ template <class T> inline void ignore_unused_variable_warning(const T&) { }
 
 // the unused, defaulted parameter is a workaround for MSVC and Compaq C++
 template <class Concept>
-inline void function_requires(type<Concept>* = 0)
+inline void function_requires(mpl::identity<Concept>* = 0)
 {
 #if !defined(NDEBUG)
   void (Concept::*x)() = BOOST_FPTR Concept::constraints;
@@ -48,6 +50,43 @@ inline void function_requires(type<Concept>* = 0)
 #endif
 }
 
+#define BOOST_CLASS_REQUIRE(type_var, ns, concept) \
+  typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
+  template <func##type_var##concept Tp1_> \
+  struct concept_checking_##type_var##concept { }; \
+  typedef concept_checking_##type_var##concept< \
+    BOOST_FPTR ns::concept<type_var>::constraints> \
+    concept_checking_typedef_##type_var##concept
+
+#define BOOST_CLASS_REQUIRE2(type_var1, type_var2, ns, concept) \
+  typedef void (ns::concept <type_var1,type_var2>::* \
+     func##type_var1##type_var2##concept)(); \
+  template <func##type_var1##type_var2##concept Tp1_> \
+  struct concept_checking_##type_var1##type_var2##concept { }; \
+  typedef concept_checking_##type_var1##type_var2##concept< \
+    BOOST_FPTR ns::concept<type_var1,type_var2>::constraints> \
+    concept_checking_typedef_##type_var1##type_var2##concept
+
+#define BOOST_CLASS_REQUIRE3(tv1, tv2, tv3, ns, concept) \
+  typedef void (ns::concept <tv1,tv2,tv3>::* \
+     func##tv1##tv2##tv3##concept)(); \
+  template <func##tv1##tv2##tv3##concept Tp1_> \
+  struct concept_checking_##tv1##tv2##tv3##concept { }; \
+  typedef concept_checking_##tv1##tv2##tv3##concept< \
+    BOOST_FPTR ns::concept<tv1,tv2,tv3>::constraints> \
+    concept_checking_typedef_##tv1##tv2##tv3##concept
+
+#define BOOST_CLASS_REQUIRE4(tv1, tv2, tv3, tv4, ns, concept) \
+  typedef void (ns::concept <tv1,tv2,tv3,tv4>::* \
+     func##tv1##tv2##tv3##tv4##concept)(); \
+  template <func##tv1##tv2##tv3##tv4##concept Tp1_> \
+  struct concept_checking_##tv1##tv2##tv3##tv4##concept { }; \
+  typedef concept_checking_##tv1##tv2##tv3##tv4##concept< \
+    BOOST_FPTR ns::concept<tv1,tv2,tv3,tv4>::constraints> \
+    concept_checking_typedef_##tv1##tv2##tv3##tv4##concept
+
+// NOTE: The BOOST_CLASS_REQUIRES (with an 'S' at the end) is deprecated.
+
 // The BOOST_CLASS_REQUIRES macros use function pointers as
 // template parameters, which VC++ does not support.
 
@@ -62,7 +101,7 @@ inline void function_requires(type<Concept>* = 0)
 
 #define BOOST_CLASS_REQUIRES(type_var, concept) \
   typedef void (concept <type_var>::* func##type_var##concept)(); \
-  template <func##type_var##concept _Tp1> \
+  template <func##type_var##concept Tp1_> \
   struct concept_checking_##type_var##concept { }; \
   typedef concept_checking_##type_var##concept< \
     BOOST_FPTR concept <type_var>::constraints> \
@@ -70,7 +109,7 @@ inline void function_requires(type<Concept>* = 0)
 
 #define BOOST_CLASS_REQUIRES2(type_var1, type_var2, concept) \
   typedef void (concept <type_var1,type_var2>::* func##type_var1##type_var2##concept)(); \
-  template <func##type_var1##type_var2##concept _Tp1> \
+  template <func##type_var1##type_var2##concept Tp1_> \
   struct concept_checking_##type_var1##type_var2##concept { }; \
   typedef concept_checking_##type_var1##type_var2##concept< \
     BOOST_FPTR concept <type_var1,type_var2>::constraints> \
@@ -78,7 +117,7 @@ inline void function_requires(type<Concept>* = 0)
 
 #define BOOST_CLASS_REQUIRES3(type_var1, type_var2, type_var3, concept) \
   typedef void (concept <type_var1,type_var2,type_var3>::* func##type_var1##type_var2##type_var3##concept)(); \
-  template <func##type_var1##type_var2##type_var3##concept _Tp1> \
+  template <func##type_var1##type_var2##type_var3##concept Tp1_> \
   struct concept_checking_##type_var1##type_var2##type_var3##concept { }; \
   typedef concept_checking_##type_var1##type_var2##type_var3##concept< \
     BOOST_FPTR concept <type_var1,type_var2,type_var3>::constraints>  \
@@ -86,7 +125,7 @@ inline void function_requires(type<Concept>* = 0)
 
 #define BOOST_CLASS_REQUIRES4(type_var1, type_var2, type_var3, type_var4, concept) \
   typedef void (concept <type_var1,type_var2,type_var3,type_var4>::* func##type_var1##type_var2##type_var3##type_var4##concept)(); \
-  template <func##type_var1##type_var2##type_var3##type_var4##concept _Tp1> \
+  template <func##type_var1##type_var2##type_var3##type_var4##concept Tp1_> \
   struct concept_checking_##type_var1##type_var2##type_var3##type_var4##concept { }; \
   typedef concept_checking_##type_var1##type_var2##type_var3##type_var4##concept< \
     BOOST_FPTR concept <type_var1,type_var2,type_var3,type_var4>::constraints>  \
@@ -140,7 +179,7 @@ struct require_same { typedef T type; };
   template <> struct SignedIntegerConcept<int> { void constraints() {} };
   template <> struct SignedIntegerConcept<long> { void constraints() {} };
 # if defined(BOOST_HAS_LONG_LONG)
-  template <> struct SignedIntegerConcept<long long> { void constraints() {} };
+  template <> struct SignedIntegerConcept< ::boost::long_long_type> { void constraints() {} };
 # endif
   // etc.
 #endif      
@@ -496,34 +535,15 @@ struct require_same { typedef T type; };
   // Iterator Concepts
 
   template <class TT>
-  struct TrivialIteratorConcept
+  struct InputIteratorConcept
   {
     void constraints() {
       function_requires< AssignableConcept<TT> >();
-      function_requires< DefaultConstructibleConcept<TT> >();
       function_requires< EqualityComparableConcept<TT> >();
+      TT j(i);
       (void)*i;           // require dereference operator
-    }
-    TT i;
-  };
-
-  template <class TT>
-  struct Mutable_TrivialIteratorConcept
-  {
-    void constraints() {
-      function_requires< TrivialIteratorConcept<TT> >();
-      *i = *j;            // require dereference and assignment
-    }
-    TT i, j;
-  };
-
-  template <class TT>
-  struct InputIteratorConcept
-  {
-    void constraints() {
-      function_requires< TrivialIteratorConcept<TT> >();
-      // require iterator_traits typedef's
 #ifndef BOOST_NO_STD_ITERATOR_TRAITS
+      // require iterator_traits typedef's
       typedef typename std::iterator_traits<TT>::difference_type D;
       // Hmm, the following is a bit fragile
       //function_requires< SignedIntegerConcept<D> >();
@@ -532,7 +552,7 @@ struct require_same { typedef T type; };
       typedef typename std::iterator_traits<TT>::iterator_category C;
       function_requires< ConvertibleConcept<C, std::input_iterator_tag> >();
 #endif
-      ++i;                // require preincrement operator
+      ++j;                // require preincrement operator
       i++;                // require postincrement operator
     }
     TT i;
@@ -668,12 +688,12 @@ struct require_same { typedef T type; };
       function_requires< AssignableConcept<Container> >();
       const_constraints(c);
     }
-    void const_constraints(const Container& c) {
-      i = c.begin();
-      i = c.end();
-      n = c.size();
-      n = c.max_size();
-      b = c.empty();
+    void const_constraints(const Container& cc) {
+      i = cc.begin();
+      i = cc.end();
+      n = cc.size();
+      n = cc.max_size();
+      b = cc.empty();
     }
     Container c;
     bool b;
@@ -737,9 +757,9 @@ struct require_same { typedef T type; };
         BidirectionalIteratorConcept<const_reverse_iterator> >();
       const_constraints(c);
     }
-    void const_constraints(const ReversibleContainer& c) {
-      const_reverse_iterator i = c.rbegin();
-      i = c.rend();
+    void const_constraints(const ReversibleContainer& cc) {
+      const_reverse_iterator i = cc.rbegin();
+      i = cc.rend();
     }
     ReversibleContainer c;
   };
@@ -781,8 +801,8 @@ struct require_same { typedef T type; };
 
       const_constraints(c);
     }
-    void const_constraints(const RandomAccessContainer& c) {
-      const_reference r = c[n];
+    void const_constraints(const RandomAccessContainer& cc) {
+      const_reference r = cc[n];
       ignore_unused_variable_warning(r);
     }
     RandomAccessContainer c;
@@ -885,8 +905,8 @@ struct require_same { typedef T type; };
       reference r = c.back();
       ignore_unused_variable_warning(r);
     }
-    void const_constraints(const BackInsertionSequence& c) {
-      const_reference r = c.back();
+    void const_constraints(const BackInsertionSequence& cc) {
+      const_reference r = cc.back();
       ignore_unused_variable_warning(r);
     };
     BackInsertionSequence c;
@@ -907,10 +927,10 @@ struct require_same { typedef T type; };
       c.erase(r.first, r.second);
       const_constraints(c);
     }
-    void const_constraints(const AssociativeContainer& c) {
-      ci = c.find(k);
-      n = c.count(k);
-      cr = c.equal_range(k);
+    void const_constraints(const AssociativeContainer& cc) {
+      ci = cc.find(k);
+      n = cc.count(k);
+      cr = cc.equal_range(k);
     }
     typedef typename AssociativeContainer::iterator iterator;
     typedef typename AssociativeContainer::const_iterator const_iterator;