Conceptions and bug fixes.
3 * src/lemon/utility.h - Part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi
6 * Kutatocsoport (Egervary Combinatorial Optimization Research Group,
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.
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
17 * This file contains a modified version of the enable_if library from BOOST.
18 * See the appropriate copyright notice below.
21 // Boost enable_if library
23 // Copyright 2003 © The Trustees of Indiana University.
25 // Use, modification, and distribution is subject to the Boost Software
26 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
27 // http://www.boost.org/LICENSE_1_0.txt)
29 // Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
30 // Jeremiah Willcock (jewillco at osl.iu.edu)
31 // Andrew Lumsdaine (lums at osl.iu.edu)
34 #ifndef LEMON_UTILITY_H
35 #define LEMON_UTILITY_H
40 /// Basic type for defining "tags". A "YES" condition for enable_if.
42 /// \todo This should go to a separate "basic_types.h" (or something)
45 static const bool value = true;
48 /// Basic type for defining "tags". A "NO" condition for enable_if.
50 static const bool value = false;
56 Wrap(const T &t) : value(t) {}
59 /**************** dummy class to avoid ambiguity ****************/
61 template<int T> struct dummy { dummy(int) {} };
63 /**************** enable_if from BOOST ****************/
65 template <bool B, class T = void>
71 struct enable_if_c<false, T> {};
73 template <class Cond, class T = void>
74 struct enable_if : public enable_if_c<Cond::value, T> {};
76 template <bool B, class T>
77 struct lazy_enable_if_c {
78 typedef typename T::type type;
82 struct lazy_enable_if_c<false, T> {};
84 template <class Cond, class T>
85 struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
88 template <bool B, class T = void>
94 struct disable_if_c<true, T> {};
96 template <class Cond, class T = void>
97 struct disable_if : public disable_if_c<Cond::value, T> {};
99 template <bool B, class T>
100 struct lazy_disable_if_c {
101 typedef typename T::type type;
105 struct lazy_disable_if_c<true, T> {};
107 template <class Cond, class T>
108 struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};