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