- Move template.h to doc/.
- Insert the license terms into the documentation.
- template.h now appears under the coding style documentation.
2 // Modified for use in LEMON.
3 // We should really consider using Boost...
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)
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)
18 // See http://www.boost.org/libs/concept_check for documentation.
20 #ifndef LEMON_BOOST_CONCEPT_CHECKS_HPP
21 #define LEMON_BOOST_CONCEPT_CHECKS_HPP
26 "inline" is used for ignore_unused_variable_warning()
27 and function_requires() to make sure there is no
31 template <class T> inline void ignore_unused_variable_warning(const T&) { }
33 template <class Concept>
34 inline void function_requires()
37 void (Concept::*x)() = & Concept::constraints;
38 ignore_unused_variable_warning(x);
42 template <typename Concept, typename Type>
43 inline void checkConcept() {
44 function_requires<typename Concept::template Constraints<Type> >();
47 #define BOOST_CLASS_REQUIRE(type_var, ns, concept) \
48 typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
49 template <func##type_var##concept Tp1_> \
50 struct concept_checking_##type_var##concept { }; \
51 typedef concept_checking_##type_var##concept< \
52 BOOST_FPTR ns::concept<type_var>::constraints> \
53 concept_checking_typedef_##type_var##concept
55 #define BOOST_CLASS_REQUIRE2(type_var1, type_var2, ns, concept) \
56 typedef void (ns::concept <type_var1,type_var2>::* \
57 func##type_var1##type_var2##concept)(); \
58 template <func##type_var1##type_var2##concept Tp1_> \
59 struct concept_checking_##type_var1##type_var2##concept { }; \
60 typedef concept_checking_##type_var1##type_var2##concept< \
61 BOOST_FPTR ns::concept<type_var1,type_var2>::constraints> \
62 concept_checking_typedef_##type_var1##type_var2##concept
64 #define BOOST_CLASS_REQUIRE3(tv1, tv2, tv3, ns, concept) \
65 typedef void (ns::concept <tv1,tv2,tv3>::* \
66 func##tv1##tv2##tv3##concept)(); \
67 template <func##tv1##tv2##tv3##concept Tp1_> \
68 struct concept_checking_##tv1##tv2##tv3##concept { }; \
69 typedef concept_checking_##tv1##tv2##tv3##concept< \
70 BOOST_FPTR ns::concept<tv1,tv2,tv3>::constraints> \
71 concept_checking_typedef_##tv1##tv2##tv3##concept
73 #define BOOST_CLASS_REQUIRE4(tv1, tv2, tv3, tv4, ns, concept) \
74 typedef void (ns::concept <tv1,tv2,tv3,tv4>::* \
75 func##tv1##tv2##tv3##tv4##concept)(); \
76 template <func##tv1##tv2##tv3##tv4##concept Tp1_> \
77 struct concept_checking_##tv1##tv2##tv3##tv4##concept { }; \
78 typedef concept_checking_##tv1##tv2##tv3##tv4##concept< \
79 BOOST_FPTR ns::concept<tv1,tv2,tv3,tv4>::constraints> \
80 concept_checking_typedef_##tv1##tv2##tv3##tv4##concept
85 #endif // LEMON_BOOST_CONCEPT_CHECKS_HPP