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