concept_check.h

00001 /* -*- C++ -*-
00002  *
00003  * This file is a part of LEMON, a generic C++ optimization library
00004  *
00005  * Copyright (C) 2003-2006
00006  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
00007  * (Egervary Research Group on Combinatorial Optimization, EGRES).
00008  *
00009  * Permission to use, modify and distribute this software is granted
00010  * provided that this copyright notice appears in all copies. For
00011  * precise terms see the accompanying LICENSE file.
00012  *
00013  * This software is provided "AS IS" with no warranty of any kind,
00014  * express or implied, and with no claim as to its suitability for any
00015  * purpose.
00016  *
00017  */
00018 
00019 // Modified for use in LEMON.
00020 // We should really consider using Boost...
00021 
00022 //
00023 // (C) Copyright Jeremy Siek 2000.
00024 // Distributed under the Boost Software License, Version 1.0. (See
00025 // accompanying file LICENSE_1_0.txt or copy at
00026 // http://www.boost.org/LICENSE_1_0.txt)
00027 //
00028 // Revision History:
00029 //   05 May   2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek)
00030 //   02 April 2001: Removed limits header altogether. (Jeremy Siek)
00031 //   01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock)
00032 //
00033 
00034 // See http://www.boost.org/libs/concept_check for documentation.
00035 
00036 #ifndef LEMON_BOOST_CONCEPT_CHECKS_HPP
00037 #define LEMON_BOOST_CONCEPT_CHECKS_HPP
00038 
00039 namespace lemon {
00040 
00041   /*
00042     "inline" is used for ignore_unused_variable_warning()
00043     and function_requires() to make sure there is no
00044     overtarget with g++.
00045   */
00046 
00047   template <class T> inline void ignore_unused_variable_warning(const T&) { }
00048 
00049   template <class Concept>
00050   inline void function_requires()
00051   {
00052 #if !defined(NDEBUG)
00053     void (Concept::*x)() = & Concept::constraints;
00054     ignore_unused_variable_warning(x);
00055 #endif
00056   }
00057 
00058   template <typename Concept, typename Type>
00059   inline void checkConcept() {
00060 #if !defined(NDEBUG)
00061     typedef typename Concept::template Constraints<Type> ConceptCheck;
00062     void (ConceptCheck::*x)() = & ConceptCheck::constraints;
00063     ignore_unused_variable_warning(x);
00064 #endif
00065   }
00066 
00067 #define BOOST_CLASS_REQUIRE(type_var, ns, concept) \
00068   typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
00069   template <func##type_var##concept Tp1_> \
00070   struct concept_checking_##type_var##concept { }; \
00071   typedef concept_checking_##type_var##concept< \
00072     BOOST_FPTR ns::concept<type_var>::constraints> \
00073     concept_checking_typedef_##type_var##concept
00074 
00075 #define BOOST_CLASS_REQUIRE2(type_var1, type_var2, ns, concept) \
00076   typedef void (ns::concept <type_var1,type_var2>::* \
00077      func##type_var1##type_var2##concept)(); \
00078   template <func##type_var1##type_var2##concept Tp1_> \
00079   struct concept_checking_##type_var1##type_var2##concept { }; \
00080   typedef concept_checking_##type_var1##type_var2##concept< \
00081     BOOST_FPTR ns::concept<type_var1,type_var2>::constraints> \
00082     concept_checking_typedef_##type_var1##type_var2##concept
00083 
00084 #define BOOST_CLASS_REQUIRE3(tv1, tv2, tv3, ns, concept) \
00085   typedef void (ns::concept <tv1,tv2,tv3>::* \
00086      func##tv1##tv2##tv3##concept)(); \
00087   template <func##tv1##tv2##tv3##concept Tp1_> \
00088   struct concept_checking_##tv1##tv2##tv3##concept { }; \
00089   typedef concept_checking_##tv1##tv2##tv3##concept< \
00090     BOOST_FPTR ns::concept<tv1,tv2,tv3>::constraints> \
00091     concept_checking_typedef_##tv1##tv2##tv3##concept
00092 
00093 #define BOOST_CLASS_REQUIRE4(tv1, tv2, tv3, tv4, ns, concept) \
00094   typedef void (ns::concept <tv1,tv2,tv3,tv4>::* \
00095      func##tv1##tv2##tv3##tv4##concept)(); \
00096   template <func##tv1##tv2##tv3##tv4##concept Tp1_> \
00097   struct concept_checking_##tv1##tv2##tv3##tv4##concept { }; \
00098   typedef concept_checking_##tv1##tv2##tv3##tv4##concept< \
00099     BOOST_FPTR ns::concept<tv1,tv2,tv3,tv4>::constraints> \
00100     concept_checking_typedef_##tv1##tv2##tv3##tv4##concept
00101 
00102 
00103 } // namespace lemon
00104 
00105 #endif // LEMON_BOOST_CONCEPT_CHECKS_HPP

Generated on Fri Feb 3 18:36:02 2006 for LEMON by  doxygen 1.4.6