|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81599 - trunk/boost/graph/property_maps
From: jewillco_at_[hidden]
Date: 2012-11-27 17:12:39
Author: jewillco
Date: 2012-11-27 17:12:39 EST (Tue, 27 Nov 2012)
New Revision: 81599
URL: http://svn.boost.org/trac/boost/changeset/81599
Log:
Added new property map that returns a constant and eats writes
Text files modified:
trunk/boost/graph/property_maps/constant_property_map.hpp | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
Modified: trunk/boost/graph/property_maps/constant_property_map.hpp
==============================================================================
--- trunk/boost/graph/property_maps/constant_property_map.hpp (original)
+++ trunk/boost/graph/property_maps/constant_property_map.hpp 2012-11-27 17:12:39 EST (Tue, 27 Nov 2012)
@@ -54,6 +54,39 @@
make_constant_property(const Value& value)
{ return constant_property_map<Key, Value>(value); }
+/**
+ * Same as above, but pretends to be writable as well.
+ */
+template <typename Key, typename Value>
+struct constant_writable_property_map {
+ typedef Key key_type;
+ typedef Value value_type;
+ typedef Value& reference;
+ typedef boost::read_write_property_map_tag category;
+
+ constant_writable_property_map()
+ : m_value()
+ { }
+
+ constant_writable_property_map(const value_type &value)
+ : m_value(value)
+ { }
+
+ constant_writable_property_map(const constant_writable_property_map& copy)
+ : m_value(copy.m_value)
+ { }
+
+ friend Value get(const constant_writable_property_map& me, Key) {return me.m_value;}
+ friend void put(const constant_writable_property_map&, Key, Value) {}
+
+ value_type m_value;
+};
+
+template <typename Key, typename Value>
+inline constant_writable_property_map<Key, Value>
+make_constant_writable_property(const Value& value)
+{ return constant_writable_property_map<Key, Value>(value); }
+
} /* namespace boost */
#endif
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk