alpar@7: /* -*- C++ -*- alpar@7: * alpar@7: * This file is a part of LEMON, a generic C++ optimization library alpar@7: * alpar@7: * Copyright (C) 2003-2007 alpar@7: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@7: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@7: * alpar@7: * Permission to use, modify and distribute this software is granted alpar@7: * provided that this copyright notice appears in all copies. For alpar@7: * precise terms see the accompanying LICENSE file. alpar@7: * alpar@7: * This software is provided "AS IS" with no warranty of any kind, alpar@7: * express or implied, and with no claim as to its suitability for any alpar@7: * purpose. alpar@7: * alpar@7: */ alpar@7: alpar@7: // This file contains a modified version of the enable_if library from BOOST. alpar@7: // See the appropriate copyright notice below. alpar@7: alpar@7: // Boost enable_if library alpar@7: alpar@7: // Copyright 2003 © The Trustees of Indiana University. alpar@7: alpar@7: // Use, modification, and distribution is subject to the Boost Software alpar@7: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at alpar@7: // http://www.boost.org/LICENSE_1_0.txt) alpar@7: alpar@7: // Authors: Jaakko Järvi (jajarvi at osl.iu.edu) alpar@7: // Jeremiah Willcock (jewillco at osl.iu.edu) alpar@7: // Andrew Lumsdaine (lums at osl.iu.edu) alpar@7: alpar@7: alpar@7: #ifndef LEMON_BITS_UTILITY_H alpar@7: #define LEMON_BITS_UTILITY_H alpar@7: alpar@7: ///\file alpar@7: ///\brief Miscellaneous basic utilities alpar@7: /// alpar@7: ///\todo Please rethink the organisation of the basic files like this. alpar@7: ///E.g. this file might be merged with invalid.h. alpar@7: alpar@7: alpar@7: namespace lemon alpar@7: { alpar@7: alpar@7: /// Basic type for defining "tags". A "YES" condition for \c enable_if. alpar@7: alpar@7: /// Basic type for defining "tags". A "YES" condition for \c enable_if. alpar@7: /// alpar@7: ///\sa False alpar@7: /// alpar@7: /// \todo This should go to a separate "basic_types.h" (or something) alpar@7: /// file. alpar@7: struct True { alpar@7: ///\e alpar@7: static const bool value = true; alpar@7: }; alpar@7: alpar@7: /// Basic type for defining "tags". A "NO" condition for \c enable_if. alpar@7: alpar@7: /// Basic type for defining "tags". A "NO" condition for \c enable_if. alpar@7: /// alpar@7: ///\sa True alpar@7: struct False { alpar@7: ///\e alpar@7: static const bool value = false; alpar@7: }; alpar@7: alpar@7: alpar@7: struct InvalidType { alpar@7: }; alpar@7: alpar@7: template alpar@7: struct Wrap { alpar@7: const T &value; alpar@7: Wrap(const T &t) : value(t) {} alpar@7: }; alpar@7: alpar@7: /**************** dummy class to avoid ambiguity ****************/ alpar@7: alpar@7: template struct dummy { dummy(int) {} }; alpar@7: alpar@7: /**************** enable_if from BOOST ****************/ alpar@7: alpar@7: template alpar@7: struct exists { alpar@7: typedef T type; alpar@7: }; alpar@7: alpar@7: alpar@7: template alpar@7: struct enable_if_c { alpar@7: typedef T type; alpar@7: }; alpar@7: alpar@7: template alpar@7: struct enable_if_c {}; alpar@7: alpar@7: template alpar@7: struct enable_if : public enable_if_c {}; alpar@7: alpar@7: template alpar@7: struct lazy_enable_if_c { alpar@7: typedef typename T::type type; alpar@7: }; alpar@7: alpar@7: template alpar@7: struct lazy_enable_if_c {}; alpar@7: alpar@7: template alpar@7: struct lazy_enable_if : public lazy_enable_if_c {}; alpar@7: alpar@7: alpar@7: template alpar@7: struct disable_if_c { alpar@7: typedef T type; alpar@7: }; alpar@7: alpar@7: template alpar@7: struct disable_if_c {}; alpar@7: alpar@7: template alpar@7: struct disable_if : public disable_if_c {}; alpar@7: alpar@7: template alpar@7: struct lazy_disable_if_c { alpar@7: typedef typename T::type type; alpar@7: }; alpar@7: alpar@7: template alpar@7: struct lazy_disable_if_c {}; alpar@7: alpar@7: template alpar@7: struct lazy_disable_if : public lazy_disable_if_c {}; alpar@7: alpar@7: } // namespace lemon alpar@7: alpar@7: #endif