Welcome to mirror list, hosted at ThFree Co, Russian Federation.

concept_check.h « lemon « lemon-1.3.1 « 3rd « quadriflow « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 38355b0f22871583729bc6c872a73f200cdf3ee7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* -*- mode: C++; indent-tabs-mode: nil; -*-
 *
 * This file is a part of LEMON, a generic C++ optimization library.
 *
 * Copyright (C) 2003-2013
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
 *
 * Permission to use, modify and distribute this software is granted
 * provided that this copyright notice appears in all copies. For
 * precise terms see the accompanying LICENSE file.
 *
 * This software is provided "AS IS" with no warranty of any kind,
 * express or implied, and with no claim as to its suitability for any
 * purpose.
 *
 */

// The contents of this file was inspired by the concept checking
// utility of the BOOST library (http://www.boost.org).

///\file
///\brief Basic utilities for concept checking.
///

#ifndef LEMON_CONCEPT_CHECK_H
#define LEMON_CONCEPT_CHECK_H

namespace lemon {

  /*
    "inline" is used for ignore_unused_variable_warning()
    and function_requires() to make sure there is no
    overtarget with g++.
  */

  template <class T> inline void ignore_unused_variable_warning(const T&) { }
  template <class T1, class T2>
  inline void ignore_unused_variable_warning(const T1&, const T2&) { }
  template <class T1, class T2, class T3>
  inline void ignore_unused_variable_warning(const T1&, const T2&,
                                             const T3&) { }
  template <class T1, class T2, class T3, class T4>
  inline void ignore_unused_variable_warning(const T1&, const T2&,
                                             const T3&, const T4&) { }
  template <class T1, class T2, class T3, class T4, class T5>
  inline void ignore_unused_variable_warning(const T1&, const T2&,
                                             const T3&, const T4&,
                                             const T5&) { }
  template <class T1, class T2, class T3, class T4, class T5, class T6>
  inline void ignore_unused_variable_warning(const T1&, const T2&,
                                             const T3&, const T4&,
                                             const T5&, const T6&) { }

  ///\e
  template <class Concept>
  inline void function_requires()
  {
#if !defined(NDEBUG)
    void (Concept::*x)() = & Concept::constraints;
    ::lemon::ignore_unused_variable_warning(x);
#endif
  }

  ///\e
  template <typename Concept, typename Type>
  inline void checkConcept() {
#if !defined(NDEBUG)
    typedef typename Concept::template Constraints<Type> ConceptCheck;
    void (ConceptCheck::*x)() = & ConceptCheck::constraints;
    ::lemon::ignore_unused_variable_warning(x);
#endif
  }

} // namespace lemon

#endif // LEMON_CONCEPT_CHECK_H