/Src/Dependencies/Boost/libs/property_map/test/property_map_cc.cpp

http://hadesmem.googlecode.com/ · C++ · 116 lines · 105 code · 3 blank · 8 comment · 0 complexity · eaba6857c90c258a6cdf047c6d2c95de MD5 · raw file

  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. function_requires<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. function_requires<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. function_requires<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. function_requires<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. function_requires<Mutable_LvaluePropertyMapConcept<PMap, Key> >();
  45. }
  46. {
  47. typedef std::ptrdiff_t Key;
  48. typedef int* PMap;
  49. function_requires<Mutable_LvaluePropertyMapConcept<PMap, Key> >();
  50. }
  51. {
  52. typedef std::ptrdiff_t Key;
  53. typedef const int* PMap;
  54. function_requires<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. function_requires<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. function_requires<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. function_requires<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. function_requires<LvaluePropertyMapConcept<PMap, Key> >();
  95. }
  96. {
  97. typedef identity_property_map PMap;
  98. function_requires<ReadablePropertyMapConcept<PMap, int> >();
  99. }
  100. {
  101. typedef dummy_property_map PMap;
  102. function_requires<ReadWritePropertyMapConcept<PMap, int> >();
  103. }
  104. {
  105. typedef sgi_assignable_archetype<> Key; // ?
  106. typedef sgi_assignable_archetype<> Value;
  107. typedef random_access_iterator_archetype<Value> Iterator;
  108. typedef readable_property_map_archetype<Key, std::ptrdiff_t> IndexMap;
  109. typedef shared_array_property_map<Value, IndexMap> PMap;
  110. function_requires<Mutable_LvaluePropertyMapConcept<PMap, Key> >();
  111. }
  112. return 0;
  113. }