blob: dd2461e7edea9cd3927997c4438ab8a63c4a198b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// (C) Copyright 2007-2009 Andrew Sutton
//
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0 (See accompanying file
// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GRAPH_CONSTANT_PROPERTY_HPP
#define BOOST_GRAPH_CONSTANT_PROPERTY_HPP
#include <boost/property_map/property_map.hpp>
// TODO: This should really be part of the property maps library rather than
// the Boost.Graph library.
namespace boost {
/**
* A constant property is one, that regardless of the edge or vertex given,
* will always return a constant value.
*/
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); }
} /* namespace boost */
#endif
|