lemon/concept_check.h
author deba
Mon, 19 Dec 2005 09:47:10 +0000
changeset 1865 dcefd1d1377f
parent 1022 567f392d1d2e
child 1956 a055123339d5
permissions -rw-r--r--
Doc fix
     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     overtarget 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   template <typename Concept, typename Type>
    43   inline void checkConcept() {
    44 #if !defined(NDEBUG)
    45     typedef typename Concept::template Constraints<Type> ConceptCheck;
    46     void (ConceptCheck::*x)() = & ConceptCheck::constraints;
    47     ignore_unused_variable_warning(x);
    48 #endif
    49   }
    50 
    51 #define BOOST_CLASS_REQUIRE(type_var, ns, concept) \
    52   typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
    53   template <func##type_var##concept Tp1_> \
    54   struct concept_checking_##type_var##concept { }; \
    55   typedef concept_checking_##type_var##concept< \
    56     BOOST_FPTR ns::concept<type_var>::constraints> \
    57     concept_checking_typedef_##type_var##concept
    58 
    59 #define BOOST_CLASS_REQUIRE2(type_var1, type_var2, ns, concept) \
    60   typedef void (ns::concept <type_var1,type_var2>::* \
    61      func##type_var1##type_var2##concept)(); \
    62   template <func##type_var1##type_var2##concept Tp1_> \
    63   struct concept_checking_##type_var1##type_var2##concept { }; \
    64   typedef concept_checking_##type_var1##type_var2##concept< \
    65     BOOST_FPTR ns::concept<type_var1,type_var2>::constraints> \
    66     concept_checking_typedef_##type_var1##type_var2##concept
    67 
    68 #define BOOST_CLASS_REQUIRE3(tv1, tv2, tv3, ns, concept) \
    69   typedef void (ns::concept <tv1,tv2,tv3>::* \
    70      func##tv1##tv2##tv3##concept)(); \
    71   template <func##tv1##tv2##tv3##concept Tp1_> \
    72   struct concept_checking_##tv1##tv2##tv3##concept { }; \
    73   typedef concept_checking_##tv1##tv2##tv3##concept< \
    74     BOOST_FPTR ns::concept<tv1,tv2,tv3>::constraints> \
    75     concept_checking_typedef_##tv1##tv2##tv3##concept
    76 
    77 #define BOOST_CLASS_REQUIRE4(tv1, tv2, tv3, tv4, ns, concept) \
    78   typedef void (ns::concept <tv1,tv2,tv3,tv4>::* \
    79      func##tv1##tv2##tv3##tv4##concept)(); \
    80   template <func##tv1##tv2##tv3##tv4##concept Tp1_> \
    81   struct concept_checking_##tv1##tv2##tv3##tv4##concept { }; \
    82   typedef concept_checking_##tv1##tv2##tv3##tv4##concept< \
    83     BOOST_FPTR ns::concept<tv1,tv2,tv3,tv4>::constraints> \
    84     concept_checking_typedef_##tv1##tv2##tv3##tv4##concept
    85 
    86 
    87 } // namespace lemon
    88 
    89 #endif // LEMON_BOOST_CONCEPT_CHECKS_HPP