src/lemon/concept_check.h
changeset 946 c94ef40a22ce
child 986 e997802b855c
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/lemon/concept_check.h	Wed Oct 27 22:38:50 2004 +0000
     1.3 @@ -0,0 +1,80 @@
     1.4 +// -*- C++ -*-
     1.5 +// Modified for use in LEMON.
     1.6 +// We should really consider using Boost...
     1.7 +
     1.8 +
     1.9 +//
    1.10 +// (C) Copyright Jeremy Siek 2000.
    1.11 +// Distributed under the Boost Software License, Version 1.0. (See
    1.12 +// accompanying file LICENSE_1_0.txt or copy at
    1.13 +// http://www.boost.org/LICENSE_1_0.txt)
    1.14 +//
    1.15 +// Revision History:
    1.16 +//   05 May   2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek)
    1.17 +//   02 April 2001: Removed limits header altogether. (Jeremy Siek)
    1.18 +//   01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock)
    1.19 +//
    1.20 +
    1.21 +// See http://www.boost.org/libs/concept_check for documentation.
    1.22 +
    1.23 +#ifndef LEMON_BOOST_CONCEPT_CHECKS_HPP
    1.24 +#define LEMON_BOOST_CONCEPT_CHECKS_HPP
    1.25 +
    1.26 +namespace lemon {
    1.27 +
    1.28 +  /*
    1.29 +    "inline" is used for ignore_unused_variable_warning()
    1.30 +    and function_requires() to make sure there is no
    1.31 +    overhead with g++.
    1.32 +  */
    1.33 +
    1.34 +  template <class T> inline void ignore_unused_variable_warning(const T&) { }
    1.35 +
    1.36 +  template <class Concept>
    1.37 +  inline void function_requires()
    1.38 +  {
    1.39 +#if !defined(NDEBUG)
    1.40 +    void (Concept::*x)() = & Concept::constraints;
    1.41 +    ignore_unused_variable_warning(x);
    1.42 +#endif
    1.43 +  }
    1.44 +
    1.45 +#define BOOST_CLASS_REQUIRE(type_var, ns, concept) \
    1.46 +  typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
    1.47 +  template <func##type_var##concept Tp1_> \
    1.48 +  struct concept_checking_##type_var##concept { }; \
    1.49 +  typedef concept_checking_##type_var##concept< \
    1.50 +    BOOST_FPTR ns::concept<type_var>::constraints> \
    1.51 +    concept_checking_typedef_##type_var##concept
    1.52 +
    1.53 +#define BOOST_CLASS_REQUIRE2(type_var1, type_var2, ns, concept) \
    1.54 +  typedef void (ns::concept <type_var1,type_var2>::* \
    1.55 +     func##type_var1##type_var2##concept)(); \
    1.56 +  template <func##type_var1##type_var2##concept Tp1_> \
    1.57 +  struct concept_checking_##type_var1##type_var2##concept { }; \
    1.58 +  typedef concept_checking_##type_var1##type_var2##concept< \
    1.59 +    BOOST_FPTR ns::concept<type_var1,type_var2>::constraints> \
    1.60 +    concept_checking_typedef_##type_var1##type_var2##concept
    1.61 +
    1.62 +#define BOOST_CLASS_REQUIRE3(tv1, tv2, tv3, ns, concept) \
    1.63 +  typedef void (ns::concept <tv1,tv2,tv3>::* \
    1.64 +     func##tv1##tv2##tv3##concept)(); \
    1.65 +  template <func##tv1##tv2##tv3##concept Tp1_> \
    1.66 +  struct concept_checking_##tv1##tv2##tv3##concept { }; \
    1.67 +  typedef concept_checking_##tv1##tv2##tv3##concept< \
    1.68 +    BOOST_FPTR ns::concept<tv1,tv2,tv3>::constraints> \
    1.69 +    concept_checking_typedef_##tv1##tv2##tv3##concept
    1.70 +
    1.71 +#define BOOST_CLASS_REQUIRE4(tv1, tv2, tv3, tv4, ns, concept) \
    1.72 +  typedef void (ns::concept <tv1,tv2,tv3,tv4>::* \
    1.73 +     func##tv1##tv2##tv3##tv4##concept)(); \
    1.74 +  template <func##tv1##tv2##tv3##tv4##concept Tp1_> \
    1.75 +  struct concept_checking_##tv1##tv2##tv3##tv4##concept { }; \
    1.76 +  typedef concept_checking_##tv1##tv2##tv3##tv4##concept< \
    1.77 +    BOOST_FPTR ns::concept<tv1,tv2,tv3,tv4>::constraints> \
    1.78 +    concept_checking_typedef_##tv1##tv2##tv3##tv4##concept
    1.79 +
    1.80 +
    1.81 +} // namespace lemon
    1.82 +
    1.83 +#endif // LEMON_BOOST_CONCEPT_CHECKS_HPP