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_set_of.hpp
10 /// \brief Include support for unordered_set constrains for the bimap container
12 #ifndef BOOST_BIMAP_UNORDERED_SET_OF_HPP
13 #define BOOST_BIMAP_UNORDERED_SET_OF_HPP
15 #if defined(_MSC_VER) && (_MSC_VER>=1200)
19 #include <boost/config.hpp>
21 #include <boost/bimap/detail/user_interface_config.hpp>
24 #include <boost/functional/hash.hpp>
25 #include <boost/mpl/bool.hpp>
27 #include <boost/concept_check.hpp>
29 #include <boost/bimap/detail/concept_tags.hpp>
31 #include <boost/bimap/tags/support/value_type_of.hpp>
33 #include <boost/bimap/detail/generate_index_binder.hpp>
34 #include <boost/bimap/detail/generate_view_binder.hpp>
35 #include <boost/bimap/detail/generate_relation_binder.hpp>
37 #include <boost/multi_index/hashed_index.hpp>
39 #include <boost/bimap/views/unordered_map_view.hpp>
40 #include <boost/bimap/views/unordered_set_view.hpp>
45 /// \brief Set Type Specification
47 This struct is used to specify an unordered_set specification.
48 It is not a container, it is just a metaprogramming facility to
49 express the type of a set. Generally, this specification will
50 be used in other place to create a container.
51 It has the same syntax that an tr1::unordered_set instantiation,
52 except that the allocator cannot be specified. The rationale behind
53 this difference is that the allocator is not part of the
54 unordered_set type specification, rather it is a container
55 configuration parameter.
56 The first parameter is the type of the objects in the set, the
57 second one is a Hash Functor that takes objects of this type, and
58 the third one is a Functor that compares them for equality.
59 Bimap binding metafunctions can be used with this class in
63 using namespace support;
65 BOOST_STATIC_ASSERT( is_set_type_of< unordered_set_of<Type> >::value )
71 unordered_set_of<Type,HashFunctor,EqualKey>::index_bind
78 hashed_unique< tag<Tag>, KeyExtractor, HashFunctor, EqualKey >
85 unordered_set_of<Type>, RightKeyType
87 > bimap_with_left_type_as_unordered_set;
93 unordered_set_of<Type>::map_view_bind
96 bimap_with_left_type_as_unordered_set
103 bimap_with_left_type_as_unordered_set
111 See also unordered_set_of_relation.
117 class HashFunctor
= hash
< BOOST_DEDUCED_TYPENAME
118 ::boost::bimaps::tags::support::value_type_of
<KeyType
>::type
>,
119 class EqualKey
= std::equal_to
< BOOST_DEDUCED_TYPENAME
120 ::boost::bimaps::tags::support::value_type_of
<KeyType
>::type
>
122 struct unordered_set_of
: public ::boost::bimaps::detail::set_type_of_tag
124 /// User type, can be tagged
125 typedef KeyType user_type
;
127 /// Type of the object that will be stored in the container
128 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
129 value_type_of
<user_type
>::type value_type
;
131 /// Hash Functor that takes value_type objects
132 typedef HashFunctor hasher
;
134 /// Functor that compare two value_type objects for equality
135 typedef EqualKey key_equal
;
137 struct lazy_concept_checked
139 BOOST_CLASS_REQUIRE ( value_type
,
140 boost
, AssignableConcept
);
142 BOOST_CLASS_REQUIRE3( hasher
, std::size_t, value_type
,
143 boost
, UnaryFunctionConcept
);
145 BOOST_CLASS_REQUIRE4( key_equal
, bool, value_type
, value_type
,
146 boost
, BinaryFunctionConcept
);
148 typedef unordered_set_of type
;
151 BOOST_BIMAP_GENERATE_INDEX_BINDER_2CP(
154 multi_index::hashed_unique
,
161 BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
164 views::unordered_map_view
167 BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
170 views::unordered_set_view
173 typedef mpl::bool_
<false> mutable_key
;
177 /// \brief Set Of Relation Specification
179 This struct is similar to unordered_set_of but it is bind logically to
180 a relation. It is used in the bimap instantiation to specify the
181 desired type of the main view. This struct implements internally
182 a metafunction named bind_to that manages the quite complicated
183 task of finding the right type of the set for the relation.
186 template<class Relation>
189 typedef -unspecified- type;
193 See also unordered_set_of, is_set_type_of_relation.
198 class HashFunctor
= hash
< _relation
>,
199 class EqualKey
= std::equal_to
< _relation
>
201 struct unordered_set_of_relation
: public ::boost::bimaps::detail::set_type_of_relation_tag
203 /// Hash Functor that takes value_type objects
204 typedef HashFunctor hasher
;
206 /// Functor that compare two value_type objects for equality
207 typedef EqualKey key_equal
;
210 BOOST_BIMAP_GENERATE_RELATION_BINDER_2CP(
220 typedef mpl::bool_
<false> left_mutable_key
;
221 typedef mpl::bool_
<false> right_mutable_key
;
225 } // namespace bimaps
229 #endif // BOOST_BIMAP_UNORDERED_SET_OF_HPP