fix doc example typo
[boost.git] / boost / bimap / unordered_multiset_of.hpp
blob3ff499d87a89d79343957b6f942afb79082b55b0
1 // Boost.Bimap
2 //
3 // Copyright (c) 2006-2007 Matias Capeletto
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 /// \file unordered_multiset_of.hpp
10 /// \brief Include support for unordered_multiset constrains for the bimap container
12 #ifndef BOOST_BIMAP_UNORDERED_MULTISET_OF_HPP
13 #define BOOST_BIMAP_UNORDERED_MULTISET_OF_HPP
15 #if defined(_MSC_VER) && (_MSC_VER>=1200)
16 #pragma once
17 #endif
19 #include <boost/config.hpp>
21 #include <boost/bimap/detail/user_interface_config.hpp>
23 #include <cstdlib>
24 #include <functional>
25 #include <boost/functional/hash.hpp>
26 #include <boost/mpl/bool.hpp>
28 #include <boost/concept_check.hpp>
30 #include <boost/bimap/detail/concept_tags.hpp>
32 #include <boost/bimap/tags/support/value_type_of.hpp>
34 #include <boost/bimap/detail/generate_index_binder.hpp>
35 #include <boost/bimap/detail/generate_view_binder.hpp>
36 #include <boost/bimap/detail/generate_relation_binder.hpp>
38 #include <boost/multi_index/hashed_index.hpp>
40 #include <boost/bimap/views/unordered_multimap_view.hpp>
41 #include <boost/bimap/views/unordered_multiset_view.hpp>
43 namespace boost {
44 namespace bimaps {
47 /// \brief Set Type Specification
48 /**
49 This struct is used to specify an unordered_multiset specification.
50 It is not a container, it is just a metaprogramming facility to
51 express the type of a set. Generally, this specification will
52 be used in other place to create a container.
53 It has the same syntax that an tr1::unordered_multiset instantiation,
54 except that the allocator cannot be specified. The rationale behind
55 this difference is that the allocator is not part of the
56 unordered_multiset type specification, rather it is a container
57 configuration parameter.
58 The first parameter is the type of the objects in the set, the
59 second one is a Hash Functor that takes objects of this type, and
60 the third one is a Functor that compares them for equality.
61 Bimap binding metafunctions can be used with this class in
62 the following way:
64 \code
65 using namespace support;
67 BOOST_STATIC_ASSERT( is_set_type_of< unordered_multiset_of<Type> >::value )
69 BOOST_STATIC_ASSERT
71 is_same
73 compute_index_type
75 unordered_multiset_of<Type,HashFunctor,EqualKey>,
76 KeyExtractor,
77 Tag
79 >::type
81 hashed_nonunique< tag<Tag>, KeyExtractor, HashFunctor, EqualKey >
83 >::value
86 typedef bimap
88 unordered_multiset_of<Type>, RightKeyType
90 > bimap_with_left_type_as_unordered_multiset;
92 BOOST_STATIC_ASSERT
94 is_same
96 compute_map_view_type
98 member_at::left,
99 bimap_with_left_type_as_unordered_multiset
101 >::type,
103 unordered_multimap_view
105 member_at::left,
106 bimap_with_left_type_as_unordered_multiset
109 >::value
112 \endcode
114 See also unordered_multiset_of_relation.
117 template
119 class KeyType,
120 class HashFunctor = hash< BOOST_DEDUCED_TYPENAME
121 ::boost::bimaps::tags::support::value_type_of<KeyType>::type >,
122 class EqualKey = std::equal_to< BOOST_DEDUCED_TYPENAME
123 ::boost::bimaps::tags::support::value_type_of<KeyType>::type >
125 struct unordered_multiset_of : public ::boost::bimaps::detail::set_type_of_tag
127 /// User type, can be tagged
128 typedef KeyType user_type;
130 /// Type of the object that will be stored in the container
131 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
132 value_type_of<user_type>::type value_type;
134 /// Hash Functor that takes value_type objects
135 typedef HashFunctor hasher;
137 /// Functor that compare two value_type objects for equality
138 typedef EqualKey key_equal;
140 struct lazy_concept_checked
142 BOOST_CLASS_REQUIRE ( value_type,
143 boost, AssignableConcept );
145 BOOST_CLASS_REQUIRE3( hasher, std::size_t, value_type,
146 boost, UnaryFunctionConcept );
148 BOOST_CLASS_REQUIRE4( key_equal, bool, value_type, value_type,
149 boost, BinaryFunctionConcept );
151 typedef unordered_multiset_of type;
154 BOOST_BIMAP_GENERATE_INDEX_BINDER_2CP(
156 // binds to
157 multi_index::hashed_non_unique,
159 // with
160 hasher,
161 key_equal
164 BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
166 // binds to
167 views::unordered_multimap_view
170 BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
172 // binds to
173 views::unordered_multiset_view
176 typedef mpl::bool_<false> mutable_key;
180 /// \brief Set Of Relation Specification
182 This struct is similar to unordered_multiset_of but it is bind logically
183 to a relation. It is used in the bimap instantiation to specify the
184 desired type of the main view. This struct implements internally
185 a metafunction named bind_to that manages the quite complicated
186 task of finding the right type of the set for the relation.
188 \code
189 template<class Relation>
190 struct bind_to
192 typedef -unspecified- type;
194 \endcode
196 See also unordered_multiset_of, is_set_type_of_relation.
199 template
201 class HashFunctor = hash< _relation >,
202 class EqualKey = std::equal_to< _relation >
204 struct unordered_multiset_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
206 /// Hash Functor that takes value_type objects
207 typedef HashFunctor hasher;
209 /// Functor that compare two value_type objects for equality
210 typedef EqualKey key_equal;
213 BOOST_BIMAP_GENERATE_RELATION_BINDER_2CP(
215 // binds to
216 unordered_multiset_of,
218 // with
219 hasher,
220 key_equal
223 typedef mpl::bool_<false> left_mutable_key;
224 typedef mpl::bool_<false> right_mutable_key;
228 } // namespace bimaps
229 } // namespace boost
232 #endif // BOOST_BIMAP_UNORDERED_MULTISET_OF_HPP