fix doc example typo
[boost.git] / boost / bimap / multiset_of.hpp
blob656cf48e31f96cbdde8fb7c106dd81126af6128d
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 multiset_of.hpp
10 /// \brief Include support for multiset constrains for the bimap container
12 #ifndef BOOST_BIMAP_MULTISET_OF_HPP
13 #define BOOST_BIMAP_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 <functional>
24 #include <boost/mpl/bool.hpp>
26 #include <boost/concept_check.hpp>
28 #include <boost/bimap/detail/concept_tags.hpp>
30 #include <boost/bimap/tags/support/value_type_of.hpp>
32 #include <boost/bimap/detail/generate_index_binder.hpp>
33 #include <boost/bimap/detail/generate_view_binder.hpp>
34 #include <boost/bimap/detail/generate_relation_binder.hpp>
36 #include <boost/multi_index/ordered_index.hpp>
38 #include <boost/bimap/views/multimap_view.hpp>
39 #include <boost/bimap/views/multiset_view.hpp>
41 namespace boost {
42 namespace bimaps {
44 /// \brief Set Type Specification
45 /**
46 This struct is used to specify a multiset specification.
47 It is not a container, it is just a metaprogramming facility to
48 express the type of a set. Generally, this specification will
49 be used in other place to create a container.
50 It has the same syntax that an std::set instantiation, except
51 that the allocator cannot be specified. The rationale behind
52 this difference is that the allocator is not part of the set
53 type specification, rather it is a container configuration
54 parameter.
55 The first parameter is the type of the objects in the multiset,
56 and the second one is a Functor that compares them.
57 Bimap binding metafunctions can be used with this class in
58 the following way:
60 \code
61 using namespace support;
63 BOOST_STATIC_ASSERT( is_set_type_of< multiset_of<Type> >::value )
65 BOOST_STATIC_ASSERT
67 is_same
69 compute_index_type
71 multiset_of<Type,KeyCompare>,
72 KeyExtractor,
73 Tag
75 >::type
77 ordered_nonunique< tag<Tag>, KeyExtractor, KeyCompare >
79 >::value
82 typedef bimap
84 multiset_of<Type>, RightKeyType
86 > bimap_with_left_type_as_multiset;
88 BOOST_STATIC_ASSERT
90 is_same
92 compute_map_view_type
94 member_at::left,
95 bimap_with_left_type_as_multiset
97 >::type,
98 multimap_view< member_at::left, bimap_with_left_type_as_multiset >
100 >::value
103 \endcode
105 See also multiset_of_relation.
108 template
110 class KeyType,
111 class KeyCompare = std::less< BOOST_DEDUCED_TYPENAME
112 ::boost::bimaps::tags::support::value_type_of<KeyType>::type >
114 struct multiset_of : public ::boost::bimaps::detail::set_type_of_tag
116 /// User type, can be tagged
117 typedef KeyType user_type;
119 /// Type of the object that will be stored in the multiset
120 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
121 value_type_of<user_type>::type value_type;
123 /// Functor that compare two keys
124 typedef KeyCompare key_compare;
126 struct lazy_concept_checked
128 BOOST_CLASS_REQUIRE ( value_type,
129 boost, AssignableConcept );
131 BOOST_CLASS_REQUIRE4( key_compare, bool, value_type, value_type,
132 boost, BinaryFunctionConcept );
134 typedef multiset_of type;
137 BOOST_BIMAP_GENERATE_INDEX_BINDER_1CP(
139 // binds to
140 multi_index::ordered_non_unique,
142 // with
143 key_compare
146 BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
148 // binds to
149 views::multimap_view
152 BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
154 // binds to
155 views::multiset_view
158 typedef mpl::bool_<false> mutable_key;
162 /// \brief Set Of Relation Specification
164 This struct is similar to multiset_of but it is bind logically to a
165 relation. It is used in the bimap instantiation to specify the
166 desired type of the main view. This struct implements internally
167 a metafunction named bind_to that manages the quite complicated
168 task of finding the right type of the set for the relation.
170 \code
171 template<class Relation>
172 struct bind_to
174 typedef -unspecified- type;
176 \endcode
178 See also multiset_of, is_set_type_of_relation.
181 template< class KeyCompare = std::less< _relation > >
182 struct multiset_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
184 /// Functor that compare two keys
185 typedef KeyCompare key_compare;
188 BOOST_BIMAP_GENERATE_RELATION_BINDER_1CP(
190 // binds to
191 multiset_of,
193 // with
194 key_compare
197 typedef mpl::bool_<false> left_mutable_key;
198 typedef mpl::bool_<false> right_mutable_key;
201 } // namespace bimaps
202 } // namespace boost
205 #endif // BOOST_BIMAP_MULTISET_OF_HPP