3 // Copyright (c) 2006-2007 Matias Capeletto
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)
19 #include <boost/config.hpp>
21 #include <boost/bimap/detail/user_interface_config.hpp>
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>
47 /// \brief Set Type Specification
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
65 using namespace support;
67 BOOST_STATIC_ASSERT( is_set_type_of< unordered_multiset_of<Type> >::value )
75 unordered_multiset_of<Type,HashFunctor,EqualKey>,
81 hashed_nonunique< tag<Tag>, KeyExtractor, HashFunctor, EqualKey >
88 unordered_multiset_of<Type>, RightKeyType
90 > bimap_with_left_type_as_unordered_multiset;
99 bimap_with_left_type_as_unordered_multiset
103 unordered_multimap_view
106 bimap_with_left_type_as_unordered_multiset
114 See also unordered_multiset_of_relation.
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(
157 multi_index::hashed_non_unique
,
164 BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
167 views::unordered_multimap_view
170 BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
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.
189 template<class Relation>
192 typedef -unspecified- type;
196 See also unordered_multiset_of, is_set_type_of_relation.
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(
216 unordered_multiset_of
,
223 typedef mpl::bool_
<false> left_mutable_key
;
224 typedef mpl::bool_
<false> right_mutable_key
;
228 } // namespace bimaps
232 #endif // BOOST_BIMAP_UNORDERED_MULTISET_OF_HPP