lemon/concept_check.h
author Alpar Juttner <alpar@cs.elte.hu>
Sat, 27 Sep 2008 13:45:50 +0200
changeset 283 66bb22401834
parent 209 765619b7cbb2
child 285 d8dc5acf739b
permissions -rw-r--r--
Merge
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     5  * Copyright (C) 2003-2008
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    11  * precise terms see the accompanying LICENSE file.
    12  *
    13  * This software is provided "AS IS" with no warranty of any kind,
    14  * express or implied, and with no claim as to its suitability for any
    15  * purpose.
    16  *
    17  */
    18 
    19 // This file contains a modified version of the concept checking
    20 // utility from BOOST.
    21 // See the appropriate copyright notice below.
    22 
    23 // (C) Copyright Jeremy Siek 2000.
    24 // Distributed under the Boost Software License, Version 1.0. (See
    25 // accompanying file LICENSE_1_0.txt or copy at
    26 // http://www.boost.org/LICENSE_1_0.txt)
    27 //
    28 // Revision History:
    29 //   05 May   2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek)
    30 //   02 April 2001: Removed limits header altogether. (Jeremy Siek)
    31 //   01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock)
    32 //
    33 
    34 // See http://www.boost.org/libs/concept_check for documentation.
    35 
    36 ///\file
    37 ///\brief Basic utilities for concept checking.
    38 ///
    39 
    40 #ifndef LEMON_CONCEPT_CHECK_H
    41 #define LEMON_CONCEPT_CHECK_H
    42 
    43 namespace lemon {
    44 
    45   /*
    46     "inline" is used for ignore_unused_variable_warning()
    47     and function_requires() to make sure there is no
    48     overtarget with g++.
    49   */
    50 
    51   template <class T> inline void ignore_unused_variable_warning(const T&) { }
    52 
    53   ///\e
    54   template <class Concept>
    55   inline void function_requires()
    56   {
    57 #if !defined(NDEBUG)
    58     void (Concept::*x)() = & Concept::constraints;
    59     ignore_unused_variable_warning(x);
    60 #endif
    61   }
    62 
    63   ///\e
    64   template <typename Concept, typename Type>
    65   inline void checkConcept() {
    66 #if !defined(NDEBUG)
    67     typedef typename Concept::template Constraints<Type> ConceptCheck;
    68     void (ConceptCheck::*x)() = & ConceptCheck::constraints;
    69     ignore_unused_variable_warning(x);
    70 #endif
    71   }
    72 
    73 } // namespace lemon
    74 
    75 #endif // LEMON_CONCEPT_CHECK_H