Chris@16
|
1 // Copyright Daniel Trebbien 2010.
|
Chris@16
|
2 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
3 // (See accompanying file LICENSE_1_0.txt or the copy at
|
Chris@16
|
4 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5
|
Chris@16
|
6 #ifndef BOOST_GRAPH_BUFFER_CONCEPTS_HPP
|
Chris@16
|
7 #define BOOST_GRAPH_BUFFER_CONCEPTS_HPP 1
|
Chris@16
|
8 #include <boost/concept_check.hpp>
|
Chris@16
|
9 #include <boost/concept/detail/concept_def.hpp>
|
Chris@16
|
10 #include <boost/property_map/property_map.hpp>
|
Chris@16
|
11 #include <boost/typeof/typeof.hpp>
|
Chris@16
|
12 #include <boost/type_traits/add_const.hpp>
|
Chris@16
|
13 #include <boost/type_traits/add_reference.hpp>
|
Chris@16
|
14 #include <boost/type_traits/remove_reference.hpp>
|
Chris@16
|
15
|
Chris@16
|
16 namespace boost {
|
Chris@16
|
17
|
Chris@16
|
18 BOOST_concept(Buffer, (B))
|
Chris@16
|
19 {
|
Chris@16
|
20 typedef typename B::value_type value_type;
|
Chris@16
|
21 typedef typename B::size_type size_type;
|
Chris@16
|
22
|
Chris@16
|
23 BOOST_CONCEPT_USAGE(Buffer) {
|
Chris@16
|
24 typedef typename boost::add_reference<value_type>::type reference;
|
Chris@16
|
25
|
Chris@16
|
26 BOOST_CONCEPT_ASSERT((Assignable<value_type>));
|
Chris@16
|
27
|
Chris@16
|
28 buf.push(g_ct);
|
Chris@16
|
29 buf.pop();
|
Chris@16
|
30 reference t = buf.top();
|
Chris@16
|
31 boost::ignore_unused_variable_warning(t);
|
Chris@16
|
32 }
|
Chris@16
|
33
|
Chris@16
|
34 void const_constraints(const B& cbuf) {
|
Chris@16
|
35 typedef typename boost::add_const<typename boost::remove_reference<value_type>::type>::type& const_reference;
|
Chris@16
|
36
|
Chris@16
|
37 const_reference ct = cbuf.top();
|
Chris@16
|
38 s = cbuf.size();
|
Chris@16
|
39 if (cbuf.empty())
|
Chris@16
|
40 dummy = __LINE__;
|
Chris@16
|
41 }
|
Chris@16
|
42
|
Chris@16
|
43 int dummy;
|
Chris@16
|
44
|
Chris@16
|
45 static const value_type g_ct;
|
Chris@16
|
46 size_type s;
|
Chris@16
|
47 B buf;
|
Chris@16
|
48 };
|
Chris@16
|
49
|
Chris@16
|
50 BOOST_concept(UpdatableQueue, (Q))
|
Chris@16
|
51 : Buffer<Q>
|
Chris@16
|
52 {
|
Chris@16
|
53 BOOST_CONCEPT_USAGE(UpdatableQueue) {
|
Chris@16
|
54 q.update(g_ct);
|
Chris@16
|
55 }
|
Chris@16
|
56
|
Chris@16
|
57 void const_constraints(const Q& cq) {
|
Chris@16
|
58 if (cq.contains(g_ct))
|
Chris@16
|
59 dummy = __LINE__;
|
Chris@16
|
60 }
|
Chris@16
|
61
|
Chris@16
|
62 int dummy;
|
Chris@16
|
63
|
Chris@16
|
64 static const typename Buffer<Q>::value_type g_ct;
|
Chris@16
|
65 Q q;
|
Chris@16
|
66 };
|
Chris@16
|
67
|
Chris@16
|
68 BOOST_concept(KeyedUpdatableQueue, (Q))
|
Chris@16
|
69 : UpdatableQueue<Q>
|
Chris@16
|
70 {
|
Chris@16
|
71 typedef typename Q::key_type key_type;
|
Chris@16
|
72 typedef typename Q::key_map key_map;
|
Chris@16
|
73
|
Chris@16
|
74 BOOST_CONCEPT_USAGE(KeyedUpdatableQueue) {
|
Chris@16
|
75 BOOST_CONCEPT_ASSERT((boost::ReadWritePropertyMapConcept<key_map, typename Buffer<Q>::value_type>));
|
Chris@16
|
76 }
|
Chris@16
|
77
|
Chris@16
|
78 void const_constraints(const Q& cq) {
|
Chris@16
|
79 km = cq.keys();
|
Chris@16
|
80 k = get(km, g_ct);
|
Chris@16
|
81 }
|
Chris@16
|
82
|
Chris@16
|
83 static const typename Buffer<Q>::value_type g_ct;
|
Chris@16
|
84 key_type k;
|
Chris@16
|
85 key_map km;
|
Chris@16
|
86 Q q;
|
Chris@16
|
87 };
|
Chris@16
|
88
|
Chris@16
|
89 } // end `namespace boost`
|
Chris@16
|
90
|
Chris@16
|
91 #endif // !BOOST_GRAPH_BUFFER_CONCEPTS_HPP
|