3 * src/lemon/utility.h - Part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2004 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" condidion 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" condidion for enable_if.
50 static const bool value = false;
56 Wrap(const T &t) : value(t) {}
61 /**************** enable_if from BOOST ****************/
63 template <bool B, class T = void>
69 struct enable_if_c<false, T> {};
71 template <class Cond, class T = void>
72 struct enable_if : public enable_if_c<Cond::value, T> {};
74 template <bool B, class T>
75 struct lazy_enable_if_c {
76 typedef typename T::type type;
80 struct lazy_enable_if_c<false, T> {};
82 template <class Cond, class T>
83 struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
86 template <bool B, class T = void>
92 struct disable_if_c<true, T> {};
94 template <class Cond, class T = void>
95 struct disable_if : public disable_if_c<Cond::value, T> {};
97 template <bool B, class T>
98 struct lazy_disable_if_c {
99 typedef typename T::type type;
103 struct lazy_disable_if_c<true, T> {};
105 template <class Cond, class T>
106 struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};