lemon/concept_check.h
author Balazs Dezso <deba@inf.elte.hu>
Thu, 23 Oct 2008 12:39:39 +0200
changeset 338 b77fb8c32707
parent 280 e7f8647ce760
child 440 88ed40ad0d4f
permissions -rw-r--r--
Fix latex image generation
alpar@209
     1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
alpar@25
     2
 *
alpar@209
     3
 * This file is a part of LEMON, a generic C++ optimization library.
alpar@25
     4
 *
alpar@39
     5
 * Copyright (C) 2003-2008
alpar@25
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@25
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@25
     8
 *
alpar@25
     9
 * Permission to use, modify and distribute this software is granted
alpar@25
    10
 * provided that this copyright notice appears in all copies. For
alpar@25
    11
 * precise terms see the accompanying LICENSE file.
alpar@25
    12
 *
alpar@25
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@25
    14
 * express or implied, and with no claim as to its suitability for any
alpar@25
    15
 * purpose.
alpar@25
    16
 *
alpar@25
    17
 */
alpar@25
    18
alpar@285
    19
// The contents of this file was inspired by the concept checking
alpar@285
    20
// utility of the BOOST library (http://www.boost.org).
alpar@25
    21
kpeter@53
    22
///\file
kpeter@53
    23
///\brief Basic utilities for concept checking.
kpeter@53
    24
///
kpeter@53
    25
kpeter@53
    26
#ifndef LEMON_CONCEPT_CHECK_H
kpeter@53
    27
#define LEMON_CONCEPT_CHECK_H
alpar@25
    28
alpar@25
    29
namespace lemon {
alpar@25
    30
alpar@25
    31
  /*
alpar@25
    32
    "inline" is used for ignore_unused_variable_warning()
alpar@25
    33
    and function_requires() to make sure there is no
alpar@25
    34
    overtarget with g++.
alpar@25
    35
  */
alpar@25
    36
alpar@25
    37
  template <class T> inline void ignore_unused_variable_warning(const T&) { }
alpar@25
    38
kpeter@53
    39
  ///\e
alpar@25
    40
  template <class Concept>
alpar@25
    41
  inline void function_requires()
alpar@25
    42
  {
alpar@25
    43
#if !defined(NDEBUG)
alpar@25
    44
    void (Concept::*x)() = & Concept::constraints;
alpar@25
    45
    ignore_unused_variable_warning(x);
alpar@25
    46
#endif
alpar@25
    47
  }
alpar@25
    48
kpeter@53
    49
  ///\e
alpar@25
    50
  template <typename Concept, typename Type>
alpar@25
    51
  inline void checkConcept() {
alpar@25
    52
#if !defined(NDEBUG)
alpar@25
    53
    typedef typename Concept::template Constraints<Type> ConceptCheck;
alpar@25
    54
    void (ConceptCheck::*x)() = & ConceptCheck::constraints;
alpar@25
    55
    ignore_unused_variable_warning(x);
alpar@25
    56
#endif
alpar@25
    57
  }
alpar@25
    58
alpar@25
    59
} // namespace lemon
alpar@25
    60
kpeter@53
    61
#endif // LEMON_CONCEPT_CHECK_H