Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

concept_check.h

00001 // -*- C++ -*-
00002 // Modified for use in LEMON.
00003 // We should really consider using Boost...
00004 
00005 
00006 //
00007 // (C) Copyright Jeremy Siek 2000.
00008 // Distributed under the Boost Software License, Version 1.0. (See
00009 // accompanying file LICENSE_1_0.txt or copy at
00010 // http://www.boost.org/LICENSE_1_0.txt)
00011 //
00012 // Revision History:
00013 //   05 May   2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek)
00014 //   02 April 2001: Removed limits header altogether. (Jeremy Siek)
00015 //   01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock)
00016 //
00017 
00018 // See http://www.boost.org/libs/concept_check for documentation.
00019 
00020 #ifndef LEMON_BOOST_CONCEPT_CHECKS_HPP
00021 #define LEMON_BOOST_CONCEPT_CHECKS_HPP
00022 
00023 namespace lemon {
00024 
00025   /*
00026     "inline" is used for ignore_unused_variable_warning()
00027     and function_requires() to make sure there is no
00028     overtarget with g++.
00029   */
00030 
00031   template <class T> inline void ignore_unused_variable_warning(const T&) { }
00032 
00033   template <class Concept>
00034   inline void function_requires()
00035   {
00036 #if !defined(NDEBUG)
00037     void (Concept::*x)() = & Concept::constraints;
00038     ignore_unused_variable_warning(x);
00039 #endif
00040   }
00041 
00042   template <typename Concept, typename Type>
00043   inline void checkConcept() {
00044 #if !defined(NDEBUG)
00045     typedef typename Concept::template Constraints<Type> ConceptCheck;
00046     void (ConceptCheck::*x)() = & ConceptCheck::constraints;
00047     ignore_unused_variable_warning(x);
00048 #endif
00049   }
00050 
00051 #define BOOST_CLASS_REQUIRE(type_var, ns, concept) \
00052   typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
00053   template <func##type_var##concept Tp1_> \
00054   struct concept_checking_##type_var##concept { }; \
00055   typedef concept_checking_##type_var##concept< \
00056     BOOST_FPTR ns::concept<type_var>::constraints> \
00057     concept_checking_typedef_##type_var##concept
00058 
00059 #define BOOST_CLASS_REQUIRE2(type_var1, type_var2, ns, concept) \
00060   typedef void (ns::concept <type_var1,type_var2>::* \
00061      func##type_var1##type_var2##concept)(); \
00062   template <func##type_var1##type_var2##concept Tp1_> \
00063   struct concept_checking_##type_var1##type_var2##concept { }; \
00064   typedef concept_checking_##type_var1##type_var2##concept< \
00065     BOOST_FPTR ns::concept<type_var1,type_var2>::constraints> \
00066     concept_checking_typedef_##type_var1##type_var2##concept
00067 
00068 #define BOOST_CLASS_REQUIRE3(tv1, tv2, tv3, ns, concept) \
00069   typedef void (ns::concept <tv1,tv2,tv3>::* \
00070      func##tv1##tv2##tv3##concept)(); \
00071   template <func##tv1##tv2##tv3##concept Tp1_> \
00072   struct concept_checking_##tv1##tv2##tv3##concept { }; \
00073   typedef concept_checking_##tv1##tv2##tv3##concept< \
00074     BOOST_FPTR ns::concept<tv1,tv2,tv3>::constraints> \
00075     concept_checking_typedef_##tv1##tv2##tv3##concept
00076 
00077 #define BOOST_CLASS_REQUIRE4(tv1, tv2, tv3, tv4, ns, concept) \
00078   typedef void (ns::concept <tv1,tv2,tv3,tv4>::* \
00079      func##tv1##tv2##tv3##tv4##concept)(); \
00080   template <func##tv1##tv2##tv3##tv4##concept Tp1_> \
00081   struct concept_checking_##tv1##tv2##tv3##tv4##concept { }; \
00082   typedef concept_checking_##tv1##tv2##tv3##tv4##concept< \
00083     BOOST_FPTR ns::concept<tv1,tv2,tv3,tv4>::constraints> \
00084     concept_checking_typedef_##tv1##tv2##tv3##tv4##concept
00085 
00086 
00087 } // namespace lemon
00088 
00089 #endif // LEMON_BOOST_CONCEPT_CHECKS_HPP

Generated on Sat Mar 19 10:58:39 2005 for LEMON by  doxygen 1.4.1