|
1 /* -*- C++ -*- |
|
2 * |
|
3 * This file is a part of LEMON, a generic C++ optimization library |
|
4 * |
|
5 * Copyright (C) 2003-2007 |
|
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
|
7 * (Egervary Research Group on Combinatorial Optimization, EGRES). |
|
8 * |
|
9 * Permission to use, modify and distribute this software is granted |
|
10 * provided that this copyright notice appears in all copies. For |
|
11 * precise terms see the accompanying LICENSE file. |
|
12 * |
|
13 * This software is provided "AS IS" with no warranty of any kind, |
|
14 * express or implied, and with no claim as to its suitability for any |
|
15 * purpose. |
|
16 * |
|
17 */ |
|
18 |
|
19 // Modified for use in LEMON. |
|
20 // We should really consider using Boost... |
|
21 |
|
22 // |
|
23 // (C) Copyright Jeremy Siek 2000. |
|
24 // Distributed under the Boost Software License, Version 1.0. (See |
|
25 // accompanying file LICENSE_1_0.txt or copy at |
|
26 // http://www.boost.org/LICENSE_1_0.txt) |
|
27 // |
|
28 // Revision History: |
|
29 // 05 May 2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek) |
|
30 // 02 April 2001: Removed limits header altogether. (Jeremy Siek) |
|
31 // 01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock) |
|
32 // |
|
33 |
|
34 // See http://www.boost.org/libs/concept_check for documentation. |
|
35 |
|
36 #ifndef LEMON_BOOST_CONCEPT_CHECKS_HPP |
|
37 #define LEMON_BOOST_CONCEPT_CHECKS_HPP |
|
38 |
|
39 namespace lemon { |
|
40 |
|
41 /* |
|
42 "inline" is used for ignore_unused_variable_warning() |
|
43 and function_requires() to make sure there is no |
|
44 overtarget with g++. |
|
45 */ |
|
46 |
|
47 template <class T> inline void ignore_unused_variable_warning(const T&) { } |
|
48 |
|
49 template <class Concept> |
|
50 inline void function_requires() |
|
51 { |
|
52 #if !defined(NDEBUG) |
|
53 void (Concept::*x)() = & Concept::constraints; |
|
54 ignore_unused_variable_warning(x); |
|
55 #endif |
|
56 } |
|
57 |
|
58 template <typename Concept, typename Type> |
|
59 inline void checkConcept() { |
|
60 #if !defined(NDEBUG) |
|
61 typedef typename Concept::template Constraints<Type> ConceptCheck; |
|
62 void (ConceptCheck::*x)() = & ConceptCheck::constraints; |
|
63 ignore_unused_variable_warning(x); |
|
64 #endif |
|
65 } |
|
66 |
|
67 #define BOOST_CLASS_REQUIRE(type_var, ns, concept) \ |
|
68 typedef void (ns::concept <type_var>::* func##type_var##concept)(); \ |
|
69 template <func##type_var##concept Tp1_> \ |
|
70 struct concept_checking_##type_var##concept { }; \ |
|
71 typedef concept_checking_##type_var##concept< \ |
|
72 BOOST_FPTR ns::concept<type_var>::constraints> \ |
|
73 concept_checking_typedef_##type_var##concept |
|
74 |
|
75 #define BOOST_CLASS_REQUIRE2(type_var1, type_var2, ns, concept) \ |
|
76 typedef void (ns::concept <type_var1,type_var2>::* \ |
|
77 func##type_var1##type_var2##concept)(); \ |
|
78 template <func##type_var1##type_var2##concept Tp1_> \ |
|
79 struct concept_checking_##type_var1##type_var2##concept { }; \ |
|
80 typedef concept_checking_##type_var1##type_var2##concept< \ |
|
81 BOOST_FPTR ns::concept<type_var1,type_var2>::constraints> \ |
|
82 concept_checking_typedef_##type_var1##type_var2##concept |
|
83 |
|
84 #define BOOST_CLASS_REQUIRE3(tv1, tv2, tv3, ns, concept) \ |
|
85 typedef void (ns::concept <tv1,tv2,tv3>::* \ |
|
86 func##tv1##tv2##tv3##concept)(); \ |
|
87 template <func##tv1##tv2##tv3##concept Tp1_> \ |
|
88 struct concept_checking_##tv1##tv2##tv3##concept { }; \ |
|
89 typedef concept_checking_##tv1##tv2##tv3##concept< \ |
|
90 BOOST_FPTR ns::concept<tv1,tv2,tv3>::constraints> \ |
|
91 concept_checking_typedef_##tv1##tv2##tv3##concept |
|
92 |
|
93 #define BOOST_CLASS_REQUIRE4(tv1, tv2, tv3, tv4, ns, concept) \ |
|
94 typedef void (ns::concept <tv1,tv2,tv3,tv4>::* \ |
|
95 func##tv1##tv2##tv3##tv4##concept)(); \ |
|
96 template <func##tv1##tv2##tv3##tv4##concept Tp1_> \ |
|
97 struct concept_checking_##tv1##tv2##tv3##tv4##concept { }; \ |
|
98 typedef concept_checking_##tv1##tv2##tv3##tv4##concept< \ |
|
99 BOOST_FPTR ns::concept<tv1,tv2,tv3,tv4>::constraints> \ |
|
100 concept_checking_typedef_##tv1##tv2##tv3##tv4##concept |
|
101 |
|
102 |
|
103 } // namespace lemon |
|
104 |
|
105 #endif // LEMON_BOOST_CONCEPT_CHECKS_HPP |