COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/lemon/concept_check.h @ 1013:b3bdd856faf4

Last change on this file since 1013:b3bdd856faf4 was 989:ca95f8b5c931, checked in by Balazs Dezso, 19 years ago

XyzConcept? moved to Xyz::Constraints
use checkConcept in the next way:

checkConcept<ErasableGraph?, ListGraph?>();
checkConcept<ReadWriteMap?<Node, Node>, PredMap?>;

File size: 3.0 KB
Line 
1// -*- C++ -*-
2// Modified for use in LEMON.
3// We should really consider using Boost...
4
5
6//
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)
11//
12// Revision History:
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)
16//
17
18// See http://www.boost.org/libs/concept_check for documentation.
19
20#ifndef LEMON_BOOST_CONCEPT_CHECKS_HPP
21#define LEMON_BOOST_CONCEPT_CHECKS_HPP
22
23namespace lemon {
24
25  /*
26    "inline" is used for ignore_unused_variable_warning()
27    and function_requires() to make sure there is no
28    overtarget with g++.
29  */
30
31  template <class T> inline void ignore_unused_variable_warning(const T&) { }
32
33  template <class Concept>
34  inline void function_requires()
35  {
36#if !defined(NDEBUG)
37    void (Concept::*x)() = & Concept::constraints;
38    ignore_unused_variable_warning(x);
39#endif
40  }
41
42  template <typename Concept, typename Type>
43  inline void checkConcept() {
44    function_requires<typename Concept::template Constraints<Type> >();
45  }
46
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
54
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
63
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
72
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
81
82
83} // namespace lemon
84
85#endif // LEMON_BOOST_CONCEPT_CHECKS_HPP
Note: See TracBrowser for help on using the repository browser.