Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

utility.h

00001 /* -*- C++ -*-
00002  *
00003  * src/lemon/utility.h - Part of LEMON, a generic C++ optimization library
00004  *
00005  * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi
00006  * Kutatocsoport (Egervary Combinatorial Optimization Research Group,
00007  * EGRES).
00008  *
00009  * Permission to use, modify and distribute this software is granted
00010  * provided that this copyright notice appears in all copies. For
00011  * precise terms see the accompanying LICENSE file.
00012  *
00013  * This software is provided "AS IS" with no warranty of any kind,
00014  * express or implied, and with no claim as to its suitability for any
00015  * purpose.
00016  *
00017  * This file contains a modified version of the enable_if library from BOOST.
00018  * See the appropriate copyright notice below.
00019  */
00020 
00021 // Boost enable_if library
00022 
00023 // Copyright 2003 © The Trustees of Indiana University.
00024 
00025 // Use, modification, and distribution is subject to the Boost Software
00026 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
00027 // http://www.boost.org/LICENSE_1_0.txt)
00028 
00029 //    Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
00030 //             Jeremiah Willcock (jewillco at osl.iu.edu)
00031 //             Andrew Lumsdaine (lums at osl.iu.edu)
00032 
00033 
00034 #ifndef LEMON_UTILITY_H
00035 #define LEMON_UTILITY_H
00036 
00037 namespace lemon
00038 {
00039 
00041 
00044   struct True {
00045     static const bool value = true;
00046   };
00047 
00049   struct False {
00050     static const bool value = false;
00051   };
00052 
00053   template <typename T>
00054   struct Wrap {
00055     const T &value;
00056     Wrap(const T &t) : value(t) {}
00057   };
00058 
00059 
00060 
00061   /**************** enable_if from BOOST ****************/
00062  
00063   template <bool B, class T = void>
00064   struct enable_if_c {
00065     typedef T type;
00066   };
00067 
00068   template <class T>
00069   struct enable_if_c<false, T> {};
00070 
00071   template <class Cond, class T = void> 
00072   struct enable_if : public enable_if_c<Cond::value, T> {};
00073 
00074   template <bool B, class T>
00075   struct lazy_enable_if_c {
00076     typedef typename T::type type;
00077   };
00078 
00079   template <class T>
00080   struct lazy_enable_if_c<false, T> {};
00081 
00082   template <class Cond, class T> 
00083   struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
00084 
00085 
00086   template <bool B, class T = void>
00087   struct disable_if_c {
00088     typedef T type;
00089   };
00090 
00091   template <class T>
00092   struct disable_if_c<true, T> {};
00093 
00094   template <class Cond, class T = void> 
00095   struct disable_if : public disable_if_c<Cond::value, T> {};
00096 
00097   template <bool B, class T>
00098   struct lazy_disable_if_c {
00099     typedef typename T::type type;
00100   };
00101 
00102   template <class T>
00103   struct lazy_disable_if_c<true, T> {};
00104 
00105   template <class Cond, class T> 
00106   struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
00107 
00108 } // namespace lemon
00109 
00110 #endif

Generated on Sat Mar 19 10:58:41 2005 for LEMON by  doxygen 1.4.1