src/lemon/concept_check.h
changeset 979 b5fb023cdb7b
child 986 e997802b855c
equal deleted inserted replaced
-1:000000000000 0:fd0a3f741e9d
       
     1 // -*- C++ -*-
       
     2 // Modified for use in LEMON.
       
     3 // We should really consider using Boost...
       
     4 
       
     5 
       
     6 //
       
     7 // (C) Copyright Jeremy Siek 2000.
       
     8 // Distributed under the Boost Software License, Version 1.0. (See
       
     9 // accompanying file LICENSE_1_0.txt or copy at
       
    10 // http://www.boost.org/LICENSE_1_0.txt)
       
    11 //
       
    12 // Revision History:
       
    13 //   05 May   2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek)
       
    14 //   02 April 2001: Removed limits header altogether. (Jeremy Siek)
       
    15 //   01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock)
       
    16 //
       
    17 
       
    18 // See http://www.boost.org/libs/concept_check for documentation.
       
    19 
       
    20 #ifndef LEMON_BOOST_CONCEPT_CHECKS_HPP
       
    21 #define LEMON_BOOST_CONCEPT_CHECKS_HPP
       
    22 
       
    23 namespace lemon {
       
    24 
       
    25   /*
       
    26     "inline" is used for ignore_unused_variable_warning()
       
    27     and function_requires() to make sure there is no
       
    28     overhead with g++.
       
    29   */
       
    30 
       
    31   template <class T> inline void ignore_unused_variable_warning(const T&) { }
       
    32 
       
    33   template <class Concept>
       
    34   inline void function_requires()
       
    35   {
       
    36 #if !defined(NDEBUG)
       
    37     void (Concept::*x)() = & Concept::constraints;
       
    38     ignore_unused_variable_warning(x);
       
    39 #endif
       
    40   }
       
    41 
       
    42 #define BOOST_CLASS_REQUIRE(type_var, ns, concept) \
       
    43   typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
       
    44   template <func##type_var##concept Tp1_> \
       
    45   struct concept_checking_##type_var##concept { }; \
       
    46   typedef concept_checking_##type_var##concept< \
       
    47     BOOST_FPTR ns::concept<type_var>::constraints> \
       
    48     concept_checking_typedef_##type_var##concept
       
    49 
       
    50 #define BOOST_CLASS_REQUIRE2(type_var1, type_var2, ns, concept) \
       
    51   typedef void (ns::concept <type_var1,type_var2>::* \
       
    52      func##type_var1##type_var2##concept)(); \
       
    53   template <func##type_var1##type_var2##concept Tp1_> \
       
    54   struct concept_checking_##type_var1##type_var2##concept { }; \
       
    55   typedef concept_checking_##type_var1##type_var2##concept< \
       
    56     BOOST_FPTR ns::concept<type_var1,type_var2>::constraints> \
       
    57     concept_checking_typedef_##type_var1##type_var2##concept
       
    58 
       
    59 #define BOOST_CLASS_REQUIRE3(tv1, tv2, tv3, ns, concept) \
       
    60   typedef void (ns::concept <tv1,tv2,tv3>::* \
       
    61      func##tv1##tv2##tv3##concept)(); \
       
    62   template <func##tv1##tv2##tv3##concept Tp1_> \
       
    63   struct concept_checking_##tv1##tv2##tv3##concept { }; \
       
    64   typedef concept_checking_##tv1##tv2##tv3##concept< \
       
    65     BOOST_FPTR ns::concept<tv1,tv2,tv3>::constraints> \
       
    66     concept_checking_typedef_##tv1##tv2##tv3##concept
       
    67 
       
    68 #define BOOST_CLASS_REQUIRE4(tv1, tv2, tv3, tv4, ns, concept) \
       
    69   typedef void (ns::concept <tv1,tv2,tv3,tv4>::* \
       
    70      func##tv1##tv2##tv3##tv4##concept)(); \
       
    71   template <func##tv1##tv2##tv3##tv4##concept Tp1_> \
       
    72   struct concept_checking_##tv1##tv2##tv3##tv4##concept { }; \
       
    73   typedef concept_checking_##tv1##tv2##tv3##tv4##concept< \
       
    74     BOOST_FPTR ns::concept<tv1,tv2,tv3,tv4>::constraints> \
       
    75     concept_checking_typedef_##tv1##tv2##tv3##tv4##concept
       
    76 
       
    77 
       
    78 } // namespace lemon
       
    79 
       
    80 #endif // LEMON_BOOST_CONCEPT_CHECKS_HPP