src/lemon/utility.h
changeset 1435 8e85e6bbefdf
parent 1434 d8475431bbbb
child 1436 e0beb94d08bf
     1.1 --- a/src/lemon/utility.h	Sat May 21 21:04:57 2005 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,153 +0,0 @@
     1.4 -/* -*- C++ -*-
     1.5 - *
     1.6 - * src/lemon/utility.h - Part of LEMON, a generic C++ optimization library
     1.7 - *
     1.8 - * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi
     1.9 - * Kutatocsoport (Egervary Research Group on Combinatorial Optimization,
    1.10 - * EGRES).
    1.11 - *
    1.12 - * Permission to use, modify and distribute this software is granted
    1.13 - * provided that this copyright notice appears in all copies. For
    1.14 - * precise terms see the accompanying LICENSE file.
    1.15 - *
    1.16 - * This software is provided "AS IS" with no warranty of any kind,
    1.17 - * express or implied, and with no claim as to its suitability for any
    1.18 - * purpose.
    1.19 - *
    1.20 - * This file contains a modified version of the enable_if library from BOOST.
    1.21 - * See the appropriate copyright notice below.
    1.22 - */
    1.23 -
    1.24 -// Boost enable_if library
    1.25 -
    1.26 -// Copyright 2003 © The Trustees of Indiana University.
    1.27 -
    1.28 -// Use, modification, and distribution is subject to the Boost Software
    1.29 -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
    1.30 -// http://www.boost.org/LICENSE_1_0.txt)
    1.31 -
    1.32 -//    Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
    1.33 -//             Jeremiah Willcock (jewillco at osl.iu.edu)
    1.34 -//             Andrew Lumsdaine (lums at osl.iu.edu)
    1.35 -
    1.36 -
    1.37 -#ifndef LEMON_UTILITY_H
    1.38 -#define LEMON_UTILITY_H
    1.39 -
    1.40 -namespace lemon
    1.41 -{
    1.42 -
    1.43 -  /// Basic type for defining "tags". A "YES" condition for enable_if.
    1.44 -
    1.45 -  /// \todo This should go to a separate "basic_types.h" (or something)
    1.46 -  /// file.
    1.47 -  struct True {
    1.48 -    static const bool value = true;
    1.49 -  };
    1.50 -
    1.51 -  /// Basic type for defining "tags". A "NO" condition for enable_if.
    1.52 -  struct False {
    1.53 -    static const bool value = false;
    1.54 -  };
    1.55 -
    1.56 -  template <typename T>
    1.57 -  struct Wrap {
    1.58 -    const T &value;
    1.59 -    Wrap(const T &t) : value(t) {}
    1.60 -  };
    1.61 -
    1.62 -  /**************** dummy class to avoid ambiguity ****************/
    1.63 -
    1.64 -  template<int T> struct dummy { dummy(int) {} };
    1.65 -
    1.66 -  /**************** enable_if from BOOST ****************/
    1.67 - 
    1.68 -  template <bool B, class T = void>
    1.69 -  struct enable_if_c {
    1.70 -    typedef T type;
    1.71 -  };
    1.72 -
    1.73 -  template <class T>
    1.74 -  struct enable_if_c<false, T> {};
    1.75 -
    1.76 -  template <class Cond, class T = void> 
    1.77 -  struct enable_if : public enable_if_c<Cond::value, T> {};
    1.78 -
    1.79 -  template <bool B, class T>
    1.80 -  struct lazy_enable_if_c {
    1.81 -    typedef typename T::type type;
    1.82 -  };
    1.83 -
    1.84 -  template <class T>
    1.85 -  struct lazy_enable_if_c<false, T> {};
    1.86 -
    1.87 -  template <class Cond, class T> 
    1.88 -  struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
    1.89 -
    1.90 -
    1.91 -  template <bool B, class T = void>
    1.92 -  struct disable_if_c {
    1.93 -    typedef T type;
    1.94 -  };
    1.95 -
    1.96 -  template <class T>
    1.97 -  struct disable_if_c<true, T> {};
    1.98 -
    1.99 -  template <class Cond, class T = void> 
   1.100 -  struct disable_if : public disable_if_c<Cond::value, T> {};
   1.101 -
   1.102 -  template <bool B, class T>
   1.103 -  struct lazy_disable_if_c {
   1.104 -    typedef typename T::type type;
   1.105 -  };
   1.106 -
   1.107 -  template <class T>
   1.108 -  struct lazy_disable_if_c<true, T> {};
   1.109 -
   1.110 -  template <class Cond, class T> 
   1.111 -  struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
   1.112 -
   1.113 -  // smart referencing
   1.114 -
   1.115 -  template <typename _Type, typename Enable = void>
   1.116 -  struct SmartReference {
   1.117 -    typedef _Type& Type;
   1.118 -  };
   1.119 -  
   1.120 -  template <typename _Type>
   1.121 -  struct SmartReference<
   1.122 -    _Type, 
   1.123 -    typename enable_if<typename _Type::NeedCopy, void>::type
   1.124 -  > {
   1.125 -    typedef _Type Type;
   1.126 -  };
   1.127 -
   1.128 -  template <typename _Type, typename Enable = void>
   1.129 -  struct SmartConstReference {
   1.130 -    typedef const _Type& Type;
   1.131 -  };
   1.132 -  
   1.133 -  template <typename _Type>
   1.134 -  struct SmartConstReference<
   1.135 -    _Type, 
   1.136 -    typename enable_if<typename _Type::NeedCopy, void>::type
   1.137 -  > {
   1.138 -    typedef const _Type Type;
   1.139 -  };
   1.140 -
   1.141 -  template <typename _Type, typename Enable = void>
   1.142 -  struct SmartParameter {
   1.143 -    typedef _Type& Type;
   1.144 -  };
   1.145 -  
   1.146 -  template <typename _Type>
   1.147 -  struct SmartParameter<
   1.148 -    _Type, 
   1.149 -    typename enable_if<typename _Type::NeedCopy, void>::type
   1.150 -  > {
   1.151 -    typedef const _Type& Type;
   1.152 -  };
   1.153 -
   1.154 -} // namespace lemon
   1.155 -
   1.156 -#endif