Some documentation got revised.
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
39 /// Basic type for defining "tags". A "YES" condition for enable_if.
41 /// \todo This should go to a separate "basic_types.h" (or something)
44 static const bool value = true;
47 /// Basic type for defining "tags". A "NO" condition for enable_if.
49 static const bool value = false;
55 Wrap(const T &t) : value(t) {}
58 /**************** dummy class to avoid ambiguity ****************/
60 template<int T> struct dummy { dummy(int) {} };
62 /**************** enable_if from BOOST ****************/
64 template <bool B, class T = void>
70 struct enable_if_c<false, T> {};
72 template <class Cond, class T = void>
73 struct enable_if : public enable_if_c<Cond::value, T> {};
75 template <bool B, class T>
76 struct lazy_enable_if_c {
77 typedef typename T::type type;
81 struct lazy_enable_if_c<false, T> {};
83 template <class Cond, class T>
84 struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
87 template <bool B, class T = void>
93 struct disable_if_c<true, T> {};
95 template <class Cond, class T = void>
96 struct disable_if : public disable_if_c<Cond::value, T> {};
98 template <bool B, class T>
99 struct lazy_disable_if_c {
100 typedef typename T::type type;
104 struct lazy_disable_if_c<true, T> {};
106 template <class Cond, class T>
107 struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
111 template <typename _Type, typename Enable = void>
112 struct SmartReference {
116 template <typename _Type>
117 struct SmartReference<
119 typename enable_if<typename _Type::NeedCopy, void>::type
124 template <typename _Type, typename Enable = void>
125 struct SmartConstReference {
126 typedef const _Type& Type;
129 template <typename _Type>
130 struct SmartConstReference<
132 typename enable_if<typename _Type::NeedCopy, void>::type
134 typedef const _Type Type;
137 template <typename _Type, typename Enable = void>
138 struct SmartParameter {
142 template <typename _Type>
143 struct SmartParameter<
145 typename enable_if<typename _Type::NeedCopy, void>::type
147 typedef const _Type& Type;