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)
8
9/// \file list_of.hpp
10/// \brief Include support for list constrains for the bimap container
11
12#ifndef BOOST_BIMAP_LIST_OF_HPP
13#define BOOST_BIMAP_LIST_OF_HPP
14
15#if defined(_MSC_VER)
16#pragma once
17#endif
18
19#include <boost/config.hpp>
20
21#include <boost/bimap/detail/user_interface_config.hpp>
22
23#include <boost/mpl/bool.hpp>
24
25#include <boost/concept_check.hpp>
26
27#include <boost/bimap/detail/concept_tags.hpp>
28
29#include <boost/bimap/tags/support/value_type_of.hpp>
30
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>
34
35#include <boost/multi_index/sequenced_index.hpp>
36
37#include <boost/bimap/views/list_map_view.hpp>
38#include <boost/bimap/views/list_set_view.hpp>
39
40namespace boost {
41namespace bimaps {
42
43
44/// \brief Set Type Specification
45/**
46This struct is used to specify a set specification.
47It is not a container, it is just a metaprogramming facility to
48express the type of a set. Generally, this specification will
49be used in other place to create a container.
50It has the same syntax that an std::list instantiation, except
51that the allocator cannot be specified. The rationale behind
52this difference is that the allocator is not part of the set
53type specification, rather it is a container configuration
54parameter.
55
56\code
57using namespace support;
58
59BOOST_STATIC_ASSERT( is_set_type_of< list_of<Type> >::value )
60
61BOOST_STATIC_ASSERT
62(
63 is_same
64 <
65 list_of<Type>::index_bind
66 <
67 KeyExtractor,
68 Tag
69
70 >::type,
71
72 sequenced< tag<Tag>, KeyExtractor >
73
74 >::value
75)
76
77typedef bimap
78<
79 list_of<Type>, RightKeyType
80
81> bimap_with_left_type_as_list;
82
83BOOST_STATIC_ASSERT
84(
85 is_same
86 <
87 list_of<Type>::map_view_bind
88 <
89 member_at::left,
90 bimap_with_left_type_as_list
91
92 >::type,
93 list_map_view< member_at::left, bimap_with_left_type_as_list >
94
95 >::value
96)
97
98\endcode
99
100See also list_of_relation.
101 **/
102
103template< class Type >
104struct list_of : public ::boost::bimaps::detail::set_type_of_tag
105{
106 /// User type, can be tagged
107 typedef Type user_type;
108
109 /// Type of the object that will be stored in the list
110 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
111 value_type_of<user_type>::type value_type;
112
113
114 struct lazy_concept_checked
115 {
116 BOOST_CLASS_REQUIRE ( value_type,
117 boost, AssignableConcept );
118
119 typedef list_of type;
120 };
121
122 BOOST_BIMAP_GENERATE_INDEX_BINDER_0CP_NO_EXTRACTOR(
123
124 // binds to
125 multi_index::sequenced
126 )
127
128 BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
129
130 // binds to
131 views::list_map_view
132 )
133
134 BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
135
136 // binds to
137 views::list_set_view
138 )
139
140 typedef mpl::bool_<true> mutable_key;
141};
142
143
144/// \brief List Of Relation Specification
145/**
146This struct is similar to list_of but it is bind logically to a
147relation. It is used in the bimap instantiation to specify the
148desired type of the main view. This struct implements internally
149a metafunction named bind_to that manages the quite complicated
150task of finding the right type of the set for the relation.
151
152\code
153template<class Relation>
154struct bind_to
155{
156 typedef -unspecified- type;
157};
158\endcode
159
160See also list_of, is_set_type_of_relation.
161 **/
162
163struct list_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
164{
165 BOOST_BIMAP_GENERATE_RELATION_BINDER_0CP(
166
167 // binds to
168 list_of
169 )
170
171 typedef mpl::bool_<true> left_mutable_key;
172 typedef mpl::bool_<true> right_mutable_key;
173};
174
175
176} // namespace bimaps
177} // namespace boost
178
179
180#endif // BOOST_BIMAP_LIST_OF_HPP
181
182

source code of boost/boost/bimap/list_of.hpp