annotate DEPENDENCIES/generic/include/boost/graph/property_maps/constant_property_map.hpp @ 118:770eb830ec19 emscripten

Typo fix
author Chris Cannam
date Wed, 18 May 2016 16:14:08 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // (C) Copyright 2007-2009 Andrew Sutton
Chris@16 2 //
Chris@16 3 // Use, modification and distribution are subject to the
Chris@16 4 // Boost Software License, Version 1.0 (See accompanying file
Chris@16 5 // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 #ifndef BOOST_GRAPH_CONSTANT_PROPERTY_HPP
Chris@16 8 #define BOOST_GRAPH_CONSTANT_PROPERTY_HPP
Chris@16 9
Chris@16 10 #include <boost/property_map/property_map.hpp>
Chris@16 11
Chris@16 12
Chris@16 13 // TODO: This should really be part of the property maps library rather than
Chris@16 14 // the Boost.Graph library.
Chris@16 15
Chris@16 16 namespace boost {
Chris@16 17
Chris@16 18 /**
Chris@16 19 * A constant property is one, that regardless of the edge or vertex given,
Chris@16 20 * will always return a constant value.
Chris@16 21 */
Chris@16 22 template <typename Key, typename Value>
Chris@16 23 struct constant_property_map
Chris@16 24 : public boost::put_get_helper<
Chris@16 25 const Value&,
Chris@16 26 constant_property_map<Key, Value>
Chris@16 27 >
Chris@16 28 {
Chris@16 29 typedef Key key_type;
Chris@16 30 typedef Value value_type;
Chris@16 31 typedef const Value& reference;
Chris@16 32 typedef boost::readable_property_map_tag category;
Chris@16 33
Chris@16 34 constant_property_map()
Chris@16 35 : m_value()
Chris@16 36 { }
Chris@16 37
Chris@16 38 constant_property_map(const value_type &value)
Chris@16 39 : m_value(value)
Chris@16 40 { }
Chris@16 41
Chris@16 42 constant_property_map(const constant_property_map& copy)
Chris@16 43 : m_value(copy.m_value)
Chris@16 44 { }
Chris@16 45
Chris@16 46 inline reference operator [](const key_type&) const
Chris@16 47 { return m_value; }
Chris@16 48
Chris@16 49 value_type m_value;
Chris@16 50 };
Chris@16 51
Chris@16 52 template <typename Key, typename Value>
Chris@16 53 inline constant_property_map<Key, Value>
Chris@16 54 make_constant_property(const Value& value)
Chris@16 55 { return constant_property_map<Key, Value>(value); }
Chris@16 56
Chris@16 57 /**
Chris@16 58 * Same as above, but pretends to be writable as well.
Chris@16 59 */
Chris@16 60 template <typename Key, typename Value>
Chris@16 61 struct constant_writable_property_map {
Chris@16 62 typedef Key key_type;
Chris@16 63 typedef Value value_type;
Chris@16 64 typedef Value& reference;
Chris@16 65 typedef boost::read_write_property_map_tag category;
Chris@16 66
Chris@16 67 constant_writable_property_map()
Chris@16 68 : m_value()
Chris@16 69 { }
Chris@16 70
Chris@16 71 constant_writable_property_map(const value_type &value)
Chris@16 72 : m_value(value)
Chris@16 73 { }
Chris@16 74
Chris@16 75 constant_writable_property_map(const constant_writable_property_map& copy)
Chris@16 76 : m_value(copy.m_value)
Chris@16 77 { }
Chris@16 78
Chris@16 79 friend Value get(const constant_writable_property_map& me, Key) {return me.m_value;}
Chris@16 80 friend void put(const constant_writable_property_map&, Key, Value) {}
Chris@16 81
Chris@16 82 value_type m_value;
Chris@16 83 };
Chris@16 84
Chris@16 85 template <typename Key, typename Value>
Chris@16 86 inline constant_writable_property_map<Key, Value>
Chris@16 87 make_constant_writable_property(const Value& value)
Chris@16 88 { return constant_writable_property_map<Key, Value>(value); }
Chris@16 89
Chris@16 90 } /* namespace boost */
Chris@16 91
Chris@16 92 #endif