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