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)
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)
19 #include <boost/config.hpp>
21 #include <boost/bimap/detail/user_interface_config.hpp>
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>
45 /// \brief Set Type Specification
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
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
62 using namespace support;
64 BOOST_STATIC_ASSERT( is_set_type_of< set_of<Type> >::value )
70 set_of<Type,KeyCompare>::index_bind
77 ordered_unique< tag<Tag>, KeyExtractor, KeyCompare >
84 set_of<Type>, RightKeyType
86 > bimap_with_left_type_as_set;
92 set_of<Type>::map_view_bind
95 bimap_with_left_type_as_set
99 map_view< member_at::left, bimap_with_left_type_as_set >
106 See also set_of_relation.
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
);
138 BOOST_BIMAP_GENERATE_INDEX_BINDER_1CP(
141 multi_index::ordered_unique
,
147 BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
153 BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
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.
172 template<class Relation>
175 typedef -unspecified- type;
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(
197 typedef mpl::bool_
<false> left_mutable_key
;
198 typedef mpl::bool_
<false> right_mutable_key
;
201 } // namespace bimaps
205 #endif // BOOST_BIMAP_SET_OF_HPP