property_map_cc.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // (C) Copyright Jeremy Siek 2001.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include <boost/property_map/property_map.hpp>
  6. #include <boost/property_map/shared_array_property_map.hpp>
  7. #include <map>
  8. // This file checks the property map concepts against the property map
  9. // archetypes to make sure they are consistent and that they compile.
  10. // This also checks all the property map classes defined in
  11. // property_map.hpp against the concept checking classes.
  12. int
  13. main()
  14. {
  15. using namespace boost;
  16. {
  17. typedef null_archetype<> Key;
  18. typedef assignable_archetype<copy_constructible_archetype<> > Value;
  19. typedef readable_property_map_archetype<Key, Value> PMap;
  20. BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept<PMap, Key>));
  21. }
  22. {
  23. typedef null_archetype<> Key;
  24. typedef assignable_archetype<copy_constructible_archetype<> > Value;
  25. typedef writable_property_map_archetype<Key, Value> PMap;
  26. BOOST_CONCEPT_ASSERT((WritablePropertyMapConcept<PMap, Key>));
  27. }
  28. {
  29. typedef null_archetype<> Key;
  30. typedef assignable_archetype<copy_constructible_archetype<> > Value;
  31. typedef read_write_property_map_archetype<Key, Value> PMap;
  32. BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept<PMap, Key>));
  33. }
  34. {
  35. typedef null_archetype<> Key;
  36. typedef assignable_archetype<copy_constructible_archetype<> > Value;
  37. typedef lvalue_property_map_archetype<Key, Value> PMap;
  38. BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept<PMap, Key>));
  39. }
  40. {
  41. typedef null_archetype<> Key;
  42. typedef assignable_archetype<copy_constructible_archetype<> > Value;
  43. typedef mutable_lvalue_property_map_archetype<Key, Value> PMap;
  44. BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept<PMap, Key>));
  45. }
  46. {
  47. typedef std::ptrdiff_t Key;
  48. typedef int* PMap;
  49. BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept<PMap, Key>));
  50. }
  51. {
  52. typedef std::ptrdiff_t Key;
  53. typedef const int* PMap;
  54. BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept<PMap, Key>));
  55. }
  56. {
  57. typedef sgi_assignable_archetype<> Key; // ?
  58. typedef sgi_assignable_archetype<> Value;
  59. typedef random_access_iterator_archetype<Value> Iterator;
  60. typedef readable_property_map_archetype<Key, std::ptrdiff_t> IndexMap;
  61. typedef iterator_property_map<Iterator, IndexMap
  62. #ifdef BOOST_NO_STD_ITERATOR_TRAITS
  63. , Value, const Value&
  64. #endif
  65. > PMap;
  66. BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept<PMap, Key>));
  67. }
  68. {
  69. typedef sgi_assignable_archetype<> Key;
  70. typedef sgi_assignable_archetype<> Value;
  71. typedef mutable_random_access_iterator_archetype<Value> Iterator;
  72. typedef readable_property_map_archetype<Key, std::ptrdiff_t> IndexMap;
  73. typedef iterator_property_map<Iterator, IndexMap
  74. #ifdef BOOST_NO_STD_ITERATOR_TRAITS
  75. , Value, Value&
  76. #endif
  77. > PMap;
  78. BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept<PMap, Key>));
  79. }
  80. {
  81. typedef sgi_assignable_archetype< less_than_comparable_archetype<> > Key;
  82. typedef default_constructible_archetype< sgi_assignable_archetype<> >
  83. Value;
  84. typedef std::map<Key, Value> Container;
  85. typedef associative_property_map<Container> PMap;
  86. BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept<PMap, Key>));
  87. }
  88. {
  89. typedef sgi_assignable_archetype< less_than_comparable_archetype<> > Key;
  90. typedef default_constructible_archetype< sgi_assignable_archetype<> >
  91. Value;
  92. typedef std::map<Key, Value> Container;
  93. typedef const_associative_property_map<Container> PMap;
  94. BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept<PMap, Key>));
  95. }
  96. {
  97. typedef identity_property_map PMap;
  98. BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept<PMap, int>));
  99. }
  100. {
  101. typedef dummy_property_map PMap;
  102. BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept<PMap, int>));
  103. }
  104. {
  105. typedef sgi_assignable_archetype<> Key; // ?
  106. typedef sgi_assignable_archetype<> Value;
  107. typedef readable_property_map_archetype<Key, std::ptrdiff_t> IndexMap;
  108. typedef shared_array_property_map<Value, IndexMap> PMap;
  109. BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept<PMap, Key>));
  110. }
  111. return 0;
  112. }