Better doc.
2 * lemon/utility.h - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi
5 * Kutatocsoport (Egervary Research Group on Combinatorial Optimization,
8 * Permission to use, modify and distribute this software is granted
9 * provided that this copyright notice appears in all copies. For
10 * precise terms see the accompanying LICENSE file.
12 * This software is provided "AS IS" with no warranty of any kind,
13 * express or implied, and with no claim as to its suitability for any
16 * This file contains a modified version of the enable_if library from BOOST.
17 * See the appropriate copyright notice below.
20 // Boost enable_if library
22 // Copyright 2003 © The Trustees of Indiana University.
24 // Use, modification, and distribution is subject to the Boost Software
25 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
26 // http://www.boost.org/LICENSE_1_0.txt)
28 // Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
29 // Jeremiah Willcock (jewillco at osl.iu.edu)
30 // Andrew Lumsdaine (lums at osl.iu.edu)
33 #ifndef LEMON_UTILITY_H
34 #define LEMON_UTILITY_H
37 ///\brief Miscellaneous basic utilities
39 ///\todo Please rethink the organisation of the basic files like this.
40 ///E.g. this file might be merged with invalid.h.
46 /// Basic type for defining "tags". A "YES" condition for \c enable_if.
48 /// Basic type for defining "tags". A "YES" condition for \c enable_if.
52 /// \todo This should go to a separate "basic_types.h" (or something)
56 static const bool value = true;
59 /// Basic type for defining "tags". A "NO" condition for \c enable_if.
61 /// Basic type for defining "tags". A "NO" condition for \c enable_if.
66 static const bool value = false;
69 template <bool left, bool right>
70 struct _CompileTimeAnd {
71 static const bool value = false;
75 struct _CompileTimeAnd<true, true> {
76 static const bool value = true;
79 template <typename Left, typename Right>
80 struct CompileTimeAnd {
81 static const bool value =
82 _CompileTimeAnd<Left::value, Right::value>::value;
88 Wrap(const T &t) : value(t) {}
91 /**************** dummy class to avoid ambiguity ****************/
93 template<int T> struct dummy { dummy(int) {} };
95 /**************** enable_if from BOOST ****************/
97 template <bool B, class T = void>
103 struct enable_if_c<false, T> {};
105 template <class Cond, class T = void>
106 struct enable_if : public enable_if_c<Cond::value, T> {};
108 template <bool B, class T>
109 struct lazy_enable_if_c {
110 typedef typename T::type type;
114 struct lazy_enable_if_c<false, T> {};
116 template <class Cond, class T>
117 struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
120 template <bool B, class T = void>
121 struct disable_if_c {
126 struct disable_if_c<true, T> {};
128 template <class Cond, class T = void>
129 struct disable_if : public disable_if_c<Cond::value, T> {};
131 template <bool B, class T>
132 struct lazy_disable_if_c {
133 typedef typename T::type type;
137 struct lazy_disable_if_c<true, T> {};
139 template <class Cond, class T>
140 struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};