buffer_concepts.hpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #ifndef BOOST_GRAPH_BUFFER_CONCEPTS_HPP
  6. #define BOOST_GRAPH_BUFFER_CONCEPTS_HPP 1
  7. #include <boost/concept_check.hpp>
  8. #include <boost/property_map/property_map.hpp>
  9. #include <boost/typeof/typeof.hpp>
  10. #include <boost/type_traits/add_const.hpp>
  11. #include <boost/type_traits/add_reference.hpp>
  12. #include <boost/type_traits/remove_reference.hpp>
  13. #include <boost/concept/detail/concept_def.hpp>
  14. namespace boost
  15. {
  16. BOOST_concept(Buffer, (B))
  17. {
  18. typedef typename B::value_type value_type;
  19. typedef typename B::size_type size_type;
  20. BOOST_CONCEPT_USAGE(Buffer)
  21. {
  22. typedef typename boost::add_reference< value_type >::type reference;
  23. BOOST_CONCEPT_ASSERT((Assignable< value_type >));
  24. buf.push(g_ct);
  25. buf.pop();
  26. reference t = buf.top();
  27. boost::ignore_unused_variable_warning(t);
  28. }
  29. void const_constraints(const B& cbuf)
  30. {
  31. typedef typename boost::add_const<
  32. typename boost::remove_reference< value_type >::type >::type&
  33. const_reference;
  34. const_reference ct = cbuf.top();
  35. s = cbuf.size();
  36. if (cbuf.empty())
  37. dummy = __LINE__;
  38. }
  39. int dummy;
  40. static const value_type g_ct;
  41. size_type s;
  42. B buf;
  43. };
  44. BOOST_concept(UpdatableQueue, (Q)) : Buffer< Q >
  45. {
  46. BOOST_CONCEPT_USAGE(UpdatableQueue) { q.update(g_ct); }
  47. void const_constraints(const Q& cq)
  48. {
  49. if (cq.contains(g_ct))
  50. dummy = __LINE__;
  51. }
  52. int dummy;
  53. static const typename Buffer< Q >::value_type g_ct;
  54. Q q;
  55. };
  56. BOOST_concept(KeyedUpdatableQueue, (Q)) : UpdatableQueue< Q >
  57. {
  58. typedef typename Q::key_type key_type;
  59. typedef typename Q::key_map key_map;
  60. BOOST_CONCEPT_USAGE(KeyedUpdatableQueue)
  61. {
  62. BOOST_CONCEPT_ASSERT((boost::ReadWritePropertyMapConcept< key_map,
  63. typename Buffer< Q >::value_type >));
  64. }
  65. void const_constraints(const Q& cq)
  66. {
  67. km = cq.keys();
  68. k = get(km, g_ct);
  69. }
  70. static const typename Buffer< Q >::value_type g_ct;
  71. key_type k;
  72. key_map km;
  73. Q q;
  74. };
  75. } // end `namespace boost`
  76. #include <boost/concept/detail/concept_undef.hpp>
  77. #endif // !BOOST_GRAPH_BUFFER_CONCEPTS_HPP