1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/lemon/concept_check.h Fri Jan 04 21:45:55 2008 +0100
1.3 @@ -0,0 +1,105 @@
1.4 +/* -*- C++ -*-
1.5 + *
1.6 + * This file is a part of LEMON, a generic C++ optimization library
1.7 + *
1.8 + * Copyright (C) 2003-2007
1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 + *
1.12 + * Permission to use, modify and distribute this software is granted
1.13 + * provided that this copyright notice appears in all copies. For
1.14 + * precise terms see the accompanying LICENSE file.
1.15 + *
1.16 + * This software is provided "AS IS" with no warranty of any kind,
1.17 + * express or implied, and with no claim as to its suitability for any
1.18 + * purpose.
1.19 + *
1.20 + */
1.21 +
1.22 +// This file contains a modified version of the concept checking
1.23 +// utility from BOOST.
1.24 +// See the appropriate copyright notice below.
1.25 +
1.26 +// (C) Copyright Jeremy Siek 2000.
1.27 +// Distributed under the Boost Software License, Version 1.0. (See
1.28 +// accompanying file LICENSE_1_0.txt or copy at
1.29 +// http://www.boost.org/LICENSE_1_0.txt)
1.30 +//
1.31 +// Revision History:
1.32 +// 05 May 2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek)
1.33 +// 02 April 2001: Removed limits header altogether. (Jeremy Siek)
1.34 +// 01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock)
1.35 +//
1.36 +
1.37 +// See http://www.boost.org/libs/concept_check for documentation.
1.38 +
1.39 +#ifndef LEMON_CONCEPT_CHECKS_H
1.40 +#define LEMON_CONCEPT_CHECKS_H
1.41 +
1.42 +namespace lemon {
1.43 +
1.44 + /*
1.45 + "inline" is used for ignore_unused_variable_warning()
1.46 + and function_requires() to make sure there is no
1.47 + overtarget with g++.
1.48 + */
1.49 +
1.50 + template <class T> inline void ignore_unused_variable_warning(const T&) { }
1.51 +
1.52 + template <class Concept>
1.53 + inline void function_requires()
1.54 + {
1.55 +#if !defined(NDEBUG)
1.56 + void (Concept::*x)() = & Concept::constraints;
1.57 + ignore_unused_variable_warning(x);
1.58 +#endif
1.59 + }
1.60 +
1.61 + template <typename Concept, typename Type>
1.62 + inline void checkConcept() {
1.63 +#if !defined(NDEBUG)
1.64 + typedef typename Concept::template Constraints<Type> ConceptCheck;
1.65 + void (ConceptCheck::*x)() = & ConceptCheck::constraints;
1.66 + ignore_unused_variable_warning(x);
1.67 +#endif
1.68 + }
1.69 +
1.70 +#define BOOST_CLASS_REQUIRE(type_var, ns, concept) \
1.71 + typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
1.72 + template <func##type_var##concept Tp1_> \
1.73 + struct concept_checking_##type_var##concept { }; \
1.74 + typedef concept_checking_##type_var##concept< \
1.75 + BOOST_FPTR ns::concept<type_var>::constraints> \
1.76 + concept_checking_typedef_##type_var##concept
1.77 +
1.78 +#define BOOST_CLASS_REQUIRE2(type_var1, type_var2, ns, concept) \
1.79 + typedef void (ns::concept <type_var1,type_var2>::* \
1.80 + func##type_var1##type_var2##concept)(); \
1.81 + template <func##type_var1##type_var2##concept Tp1_> \
1.82 + struct concept_checking_##type_var1##type_var2##concept { }; \
1.83 + typedef concept_checking_##type_var1##type_var2##concept< \
1.84 + BOOST_FPTR ns::concept<type_var1,type_var2>::constraints> \
1.85 + concept_checking_typedef_##type_var1##type_var2##concept
1.86 +
1.87 +#define BOOST_CLASS_REQUIRE3(tv1, tv2, tv3, ns, concept) \
1.88 + typedef void (ns::concept <tv1,tv2,tv3>::* \
1.89 + func##tv1##tv2##tv3##concept)(); \
1.90 + template <func##tv1##tv2##tv3##concept Tp1_> \
1.91 + struct concept_checking_##tv1##tv2##tv3##concept { }; \
1.92 + typedef concept_checking_##tv1##tv2##tv3##concept< \
1.93 + BOOST_FPTR ns::concept<tv1,tv2,tv3>::constraints> \
1.94 + concept_checking_typedef_##tv1##tv2##tv3##concept
1.95 +
1.96 +#define BOOST_CLASS_REQUIRE4(tv1, tv2, tv3, tv4, ns, concept) \
1.97 + typedef void (ns::concept <tv1,tv2,tv3,tv4>::* \
1.98 + func##tv1##tv2##tv3##tv4##concept)(); \
1.99 + template <func##tv1##tv2##tv3##tv4##concept Tp1_> \
1.100 + struct concept_checking_##tv1##tv2##tv3##tv4##concept { }; \
1.101 + typedef concept_checking_##tv1##tv2##tv3##tv4##concept< \
1.102 + BOOST_FPTR ns::concept<tv1,tv2,tv3,tv4>::constraints> \
1.103 + concept_checking_typedef_##tv1##tv2##tv3##tv4##concept
1.104 +
1.105 +
1.106 +} // namespace lemon
1.107 +
1.108 +#endif // LEMON_CONCEPT_CHECKS_H