fix doc example typo
[boost.git] / boost / bimap / set_of.hpp
blobcaffa213184e08b75d06e116a3043ecad5a562c6
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 set_of.hpp
10 /// \brief Include support for set constrains for the bimap container
12 #ifndef BOOST_BIMAP_SET_OF_HPP
13 #define BOOST_BIMAP_SET_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>
25 #include <boost/mpl/aux_/na.hpp>
27 #include <boost/concept_check.hpp>
29 #include <boost/bimap/detail/concept_tags.hpp>
31 #include <boost/bimap/detail/generate_index_binder.hpp>
32 #include <boost/bimap/detail/generate_view_binder.hpp>
33 #include <boost/bimap/detail/generate_relation_binder.hpp>
35 #include <boost/bimap/tags/support/value_type_of.hpp>
37 #include <boost/multi_index/ordered_index.hpp>
39 #include <boost/bimap/views/map_view.hpp>
40 #include <boost/bimap/views/set_view.hpp>
42 namespace boost {
43 namespace bimaps {
45 /// \brief Set Type Specification
46 /**
47 This struct is used to specify a 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 std::set instantiation, except
52 that the allocator cannot be specified. The rationale behind
53 this difference is that the allocator is not part of the set
54 type specification, rather it is a container configuration
55 parameter.
56 The first parameter is the type of the objects in the set, and
57 the second one is a Functor that compares them.
58 Bimap binding metafunctions can be used with this class in
59 the following way:
61 \code
62 using namespace support;
64 BOOST_STATIC_ASSERT( is_set_type_of< set_of<Type> >::value )
66 BOOST_STATIC_ASSERT
68 is_same
70 set_of<Type,KeyCompare>::index_bind
72 KeyExtractor,
73 Tag
75 >::type,
77 ordered_unique< tag<Tag>, KeyExtractor, KeyCompare >
79 >::value
82 typedef bimap
84 set_of<Type>, RightKeyType
86 > bimap_with_left_type_as_set;
88 BOOST_STATIC_ASSERT
90 is_same
92 set_of<Type>::map_view_bind
94 member_at::left,
95 bimap_with_left_type_as_set
97 >::type,
99 map_view< member_at::left, bimap_with_left_type_as_set >
101 >::value
104 \endcode
106 See also set_of_relation.
109 template
111 class KeyType,
112 class KeyCompare = std::less< BOOST_DEDUCED_TYPENAME
113 ::boost::bimaps::tags::support::value_type_of<KeyType>::type >
115 struct set_of : public ::boost::bimaps::detail::set_type_of_tag
117 /// User type, can be tagged
118 typedef KeyType user_type;
120 /// Type of the object that will be stored in the set
121 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
122 value_type_of<user_type>::type value_type;
124 /// Functor that compare two keys
125 typedef KeyCompare key_compare;
127 struct lazy_concept_checked
129 BOOST_CLASS_REQUIRE ( value_type,
130 boost, AssignableConcept );
132 BOOST_CLASS_REQUIRE4( key_compare, bool, value_type, value_type,
133 boost, BinaryFunctionConcept );
135 typedef set_of type;
138 BOOST_BIMAP_GENERATE_INDEX_BINDER_1CP(
140 // binds to
141 multi_index::ordered_unique,
143 // with
144 key_compare
147 BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
149 // binds to
150 views::map_view
153 BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
155 // binds to
156 views::set_view
159 typedef mpl::bool_<false> mutable_key;
163 /// \brief Set Of Relation Specification
165 This struct is similar to set_of but it is bind logically to a
166 relation. It is used in the bimap instantiation to specify the
167 desired type of the main view. This struct implements internally
168 a metafunction named bind_to that manages the quite complicated
169 task of finding the right type of the set for the relation.
171 \code
172 template<class Relation>
173 struct bind_to
175 typedef -unspecified- type;
177 \endcode
179 See also set_of, is_set_type_of_relation.
182 template< class KeyCompare = std::less< _relation > >
183 struct set_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
185 /// Functor that compare two keys
186 typedef KeyCompare key_compare;
188 BOOST_BIMAP_GENERATE_RELATION_BINDER_1CP(
190 // binds to
191 set_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_SET_OF_HPP