1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #ifndef BOOST_GRAPH_CONSTANT_PROPERTY_HPP
- #define BOOST_GRAPH_CONSTANT_PROPERTY_HPP
- #include <boost/property_map/property_map.hpp>
- namespace boost
- {
- template < typename Key, typename Value >
- struct constant_property_map : public boost::put_get_helper< const Value&,
- constant_property_map< Key, Value > >
- {
- typedef Key key_type;
- typedef Value value_type;
- typedef const Value& reference;
- typedef boost::readable_property_map_tag category;
- constant_property_map() : m_value() {}
- constant_property_map(const value_type& value) : m_value(value) {}
- constant_property_map(const constant_property_map& copy)
- : m_value(copy.m_value)
- {
- }
- inline reference operator[](const key_type&) const { return m_value; }
- value_type m_value;
- };
- template < typename Key, typename Value >
- inline constant_property_map< Key, Value > make_constant_property(
- const Value& value)
- {
- return constant_property_map< Key, Value >(value);
- }
- 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);
- }
- }
- #endif
|