[Lemon-commits] Alpar Juttner: Merge (redo buggy merge ad7f59339...
Lemon HG
hg at lemon.cs.elte.hu
Thu Feb 7 22:43:49 CET 2008
details: http://lemon.cs.elte.hu/hg/lemon/rev/bfbc57a51fbb
changeset: 65:bfbc57a51fbb
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Wed Feb 06 10:52:58 2008 +0000
description:
Merge (redo buggy merge ad7f593399b0)
diffstat:
6 files changed, 1994 insertions(+), 1 deletion(-)
lemon/Makefile.am | 5
lemon/concept_check.h | 105 +++
lemon/concepts/maps.h | 207 ++++++
lemon/maps.h | 1568 +++++++++++++++++++++++++++++++++++++++++++++++++
test/Makefile.am | 2
test/maps_test.cc | 108 +++
diffs (truncated from 2044 to 300 lines):
diff -r 1f781d1f9b79 -r bfbc57a51fbb lemon/Makefile.am
--- a/lemon/Makefile.am Thu Jan 03 14:58:42 2008 +0100
+++ b/lemon/Makefile.am Wed Feb 06 10:52:58 2008 +0000
@@ -15,13 +15,16 @@ lemon_libemon_la_LDFLAGS = $(GLPK_LIBS)
lemon_libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS) $(SOPLEX_LIBS)
lemon_HEADERS += \
+ lemon/concept_check.h \
lemon/dim2.h \
lemon/random.h \
lemon/list_graph.h \
+ lemon/maps.h \
lemon/tolerance.h
bits_HEADERS += \
lemon/bits/invalid.h \
lemon/bits/utility.h
-concept_HEADERS +=
+concept_HEADERS += \
+ lemon/concepts/maps.h
diff -r 1f781d1f9b79 -r bfbc57a51fbb lemon/concept_check.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lemon/concept_check.h Wed Feb 06 10:52:58 2008 +0000
@@ -0,0 +1,105 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2007
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+// This file contains a modified version of the concept checking
+// utility from BOOST.
+// See the appropriate copyright notice below.
+
+// (C) Copyright Jeremy Siek 2000.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// Revision History:
+// 05 May 2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek)
+// 02 April 2001: Removed limits header altogether. (Jeremy Siek)
+// 01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock)
+//
+
+// See http://www.boost.org/libs/concept_check for documentation.
+
+#ifndef LEMON_CONCEPT_CHECKS_H
+#define LEMON_CONCEPT_CHECKS_H
+
+namespace lemon {
+
+ /*
+ "inline" is used for ignore_unused_variable_warning()
+ and function_requires() to make sure there is no
+ overtarget with g++.
+ */
+
+ template <class T> inline void ignore_unused_variable_warning(const T&) { }
+
+ template <class Concept>
+ inline void function_requires()
+ {
+#if !defined(NDEBUG)
+ void (Concept::*x)() = & Concept::constraints;
+ ignore_unused_variable_warning(x);
+#endif
+ }
+
+ template <typename Concept, typename Type>
+ inline void checkConcept() {
+#if !defined(NDEBUG)
+ typedef typename Concept::template Constraints<Type> ConceptCheck;
+ void (ConceptCheck::*x)() = & ConceptCheck::constraints;
+ ignore_unused_variable_warning(x);
+#endif
+ }
+
+#define BOOST_CLASS_REQUIRE(type_var, ns, concept) \
+ typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
+ template <func##type_var##concept Tp1_> \
+ struct concept_checking_##type_var##concept { }; \
+ typedef concept_checking_##type_var##concept< \
+ BOOST_FPTR ns::concept<type_var>::constraints> \
+ concept_checking_typedef_##type_var##concept
+
+#define BOOST_CLASS_REQUIRE2(type_var1, type_var2, ns, concept) \
+ typedef void (ns::concept <type_var1,type_var2>::* \
+ func##type_var1##type_var2##concept)(); \
+ template <func##type_var1##type_var2##concept Tp1_> \
+ struct concept_checking_##type_var1##type_var2##concept { }; \
+ typedef concept_checking_##type_var1##type_var2##concept< \
+ BOOST_FPTR ns::concept<type_var1,type_var2>::constraints> \
+ concept_checking_typedef_##type_var1##type_var2##concept
+
+#define BOOST_CLASS_REQUIRE3(tv1, tv2, tv3, ns, concept) \
+ typedef void (ns::concept <tv1,tv2,tv3>::* \
+ func##tv1##tv2##tv3##concept)(); \
+ template <func##tv1##tv2##tv3##concept Tp1_> \
+ struct concept_checking_##tv1##tv2##tv3##concept { }; \
+ typedef concept_checking_##tv1##tv2##tv3##concept< \
+ BOOST_FPTR ns::concept<tv1,tv2,tv3>::constraints> \
+ concept_checking_typedef_##tv1##tv2##tv3##concept
+
+#define BOOST_CLASS_REQUIRE4(tv1, tv2, tv3, tv4, ns, concept) \
+ typedef void (ns::concept <tv1,tv2,tv3,tv4>::* \
+ func##tv1##tv2##tv3##tv4##concept)(); \
+ template <func##tv1##tv2##tv3##tv4##concept Tp1_> \
+ struct concept_checking_##tv1##tv2##tv3##tv4##concept { }; \
+ typedef concept_checking_##tv1##tv2##tv3##tv4##concept< \
+ BOOST_FPTR ns::concept<tv1,tv2,tv3,tv4>::constraints> \
+ concept_checking_typedef_##tv1##tv2##tv3##tv4##concept
+
+
+} // namespace lemon
+
+#endif // LEMON_CONCEPT_CHECKS_H
diff -r 1f781d1f9b79 -r bfbc57a51fbb lemon/concepts/maps.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lemon/concepts/maps.h Wed Feb 06 10:52:58 2008 +0000
@@ -0,0 +1,207 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2007
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#ifndef LEMON_CONCEPT_MAPS_H
+#define LEMON_CONCEPT_MAPS_H
+
+#include <lemon/bits/utility.h>
+#include <lemon/concept_check.h>
+
+///\ingroup concept
+///\file
+///\brief Map concepts checking classes for testing and documenting.
+
+namespace lemon {
+
+ namespace concepts {
+
+ /// \addtogroup concept
+ /// @{
+
+ /// Readable map concept
+
+ /// Readable map concept.
+ ///
+ template<typename K, typename T>
+ class ReadMap
+ {
+ public:
+ /// Map's key type.
+ typedef K Key;
+ /// Map's value type. (The type of objects associated with the keys).
+ typedef T Value;
+
+ /// Returns the value associated with a key.
+
+ /// \bug Value shouldn't need to be default constructible.
+ ///
+ Value operator[](const Key &) const {return Value();}
+
+ template<typename _ReadMap>
+ struct Constraints {
+
+ void constraints() {
+ Value val = m[key];
+ val = m[key];
+ typename _ReadMap::Value own_val = m[own_key];
+ own_val = m[own_key];
+
+ ignore_unused_variable_warning(val);
+ ignore_unused_variable_warning(own_val);
+ ignore_unused_variable_warning(key);
+ }
+ Key& key;
+ typename _ReadMap::Key& own_key;
+ _ReadMap& m;
+ };
+
+ };
+
+
+ /// Writable map concept
+
+ /// Writable map concept.
+ ///
+ template<typename K, typename T>
+ class WriteMap
+ {
+ public:
+ /// Map's key type.
+ typedef K Key;
+ /// Map's value type. (The type of objects associated with the keys).
+ typedef T Value;
+
+ /// Sets the value associated with a key.
+ void set(const Key &,const Value &) {}
+
+ ///Default constructor
+ WriteMap() {}
+
+ template <typename _WriteMap>
+ struct Constraints {
+ void constraints() {
+ // No constraints for constructor.
+ m.set(key, val);
+ m.set(own_key, own_val);
+ ignore_unused_variable_warning(key);
+ ignore_unused_variable_warning(val);
+ ignore_unused_variable_warning(own_key);
+ ignore_unused_variable_warning(own_val);
+ }
+
+ Value& val;
+ typename _WriteMap::Value own_val;
+ Key& key;
+ typename _WriteMap::Key& own_key;
+ _WriteMap& m;
+
+ };
+ };
+
+ /// Read/Writable map concept
+
+ /// Read/writable map concept.
+ ///
+ template<typename K, typename T>
+ class ReadWriteMap : public ReadMap<K,T>,
+ public WriteMap<K,T>
+ {
+ public:
+ /// Map's key type.
+ typedef K Key;
+ /// Map's value type. (The type of objects associated with the keys).
+ typedef T Value;
+
+ /// Returns the value associated with a key.
+ Value operator[](const Key &) const {return Value();}
+ /// Sets the value associated with a key.
+ void set(const Key & ,const Value &) {}
+
+ template<typename _ReadWriteMap>
+ struct Constraints {
+ void constraints() {
+ checkConcept<ReadMap<K, T>, _ReadWriteMap >();
+ checkConcept<WriteMap<K, T>, _ReadWriteMap >();
+ }
+ };
+ };
+
+
+ /// Dereferable map concept
+
+ /// Dereferable map concept.
+ ///
+ template<typename K, typename T, typename R, typename CR>
+ class ReferenceMap : public ReadWriteMap<K,T>
+ {
+ public:
+ /// Tag for reference maps.
+ typedef True ReferenceMapTag;
+ /// Map's key type.
+ typedef K Key;
+ /// Map's value type. (The type of objects associated with the keys).
+ typedef T Value;
+ /// Map's reference type.
+ typedef R Reference;
+ /// Map's const reference type.
+ typedef CR ConstReference;
+
+ protected:
+ Value tmp;
+ public:
More information about the Lemon-commits
mailing list