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