annotate DEPENDENCIES/generic/include/boost/bimap/bimap.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // Boost.Bimap
Chris@16 2 //
Chris@16 3 // Copyright (c) 2006-2007 Matias Capeletto
Chris@16 4 //
Chris@16 5 // Distributed under the Boost Software License, Version 1.0.
Chris@16 6 // (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8
Chris@16 9 /// \file bimap.hpp
Chris@16 10 /// \brief Includes the basic bimap container
Chris@16 11
Chris@16 12 /** \mainpage notitle
Chris@16 13 \n
Chris@16 14 \image html http://matias.capeletto.googlepages.com/boost.bimap.reference.logo.png
Chris@16 15
Chris@16 16 \section Introduction
Chris@16 17
Chris@16 18 This is the complete reference of Boost.Bimap.
Chris@16 19
Chris@16 20 After getting a good understanding of the library from a user perspective
Chris@16 21 the next step will be:
Chris@16 22
Chris@16 23 - Understand the tagged idiom. (boost::bimaps::tags)
Chris@16 24 - Understand the internals of the relation class (boost::bimaps::relation)
Chris@16 25 - Read the container_adaptor toolbox docs (boost::bimaps::container_adaptor)
Chris@16 26 - Understand the internals of the bimap class. (boost::bimaps, boost::bimaps::views
Chris@16 27 and boost::bimaps::detail)
Chris@16 28
Chris@16 29
Chris@16 30 **/
Chris@16 31
Chris@16 32 /** \defgroup mutant_group mutant idiom
Chris@16 33 \brief A safe wrapper around reinterpret_cast
Chris@16 34 **/
Chris@16 35
Chris@16 36 /** \defgroup relation_group relation
Chris@16 37 \brief The relation
Chris@16 38 **/
Chris@16 39
Chris@16 40 /** \defgroup tags_group tagged idiom
Chris@16 41 \brief The tagged idiom
Chris@16 42 **/
Chris@16 43
Chris@16 44
Chris@16 45 #ifndef BOOST_BIMAP_BIMAP_HPP
Chris@16 46 #define BOOST_BIMAP_BIMAP_HPP
Chris@16 47
Chris@101 48 #if defined(_MSC_VER)
Chris@16 49 #pragma once
Chris@16 50 #endif
Chris@16 51
Chris@16 52 #include <boost/config.hpp>
Chris@16 53 #include <boost/bimap/detail/user_interface_config.hpp>
Chris@16 54 #include <boost/mpl/aux_/na.hpp>
Chris@16 55
Chris@16 56 #ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
Chris@16 57 #include <boost/serialization/nvp.hpp>
Chris@16 58 #endif // BOOST_BIMAP_DISABLE_SERIALIZATION
Chris@16 59
Chris@16 60 // Boost.Bimap
Chris@16 61 #include <boost/bimap/detail/bimap_core.hpp>
Chris@16 62 #include <boost/bimap/detail/map_view_base.hpp>
Chris@16 63 #include <boost/bimap/detail/modifier_adaptor.hpp>
Chris@16 64 #include <boost/bimap/relation/support/data_extractor.hpp>
Chris@16 65 #include <boost/bimap/relation/support/member_with_tag.hpp>
Chris@16 66
Chris@16 67 #include <boost/bimap/support/map_type_by.hpp>
Chris@16 68 #include <boost/bimap/support/map_by.hpp>
Chris@16 69 #include <boost/bimap/support/iterator_type_by.hpp>
Chris@16 70
Chris@16 71 /// \brief The namespace where all the boost libraries lives.
Chris@16 72
Chris@16 73 namespace boost {
Chris@16 74
Chris@16 75 /// \brief Boost.Bimap library namespace
Chris@16 76 /**
Chris@16 77 All the entities in the library are defined in this namespace.
Chris@16 78 **/
Chris@16 79 namespace bimaps {
Chris@16 80
Chris@16 81 /// \brief The bimap class is the entry point to the library.
Chris@16 82 /**
Chris@16 83 This class manages the instantiation of the desired bimap type.
Chris@16 84 As there are several types of bidirectional maps that can be
Chris@16 85 created using it. the main job of it is to find the desired
Chris@16 86 type. This is done using metaprogramming to obtain the relation
Chris@16 87 type that will be stored, the map_view type of each side and
Chris@16 88 the set_view type of the general relationship. The instantiation
Chris@16 89 is kept simple using an extended standard set theory, where a
Chris@16 90 bidirectional map type is defined by the set types it relates.
Chris@16 91 For example, a bidirectional map that has multimap semantics
Chris@16 92 viewed from both sides is defined by specifying that the two
Chris@16 93 keys sets are of \c multiset_of<Key> type.
Chris@16 94 This allows the bimap class to support seamingless N-N, 1-N,
Chris@16 95 ordered/unordered and even vector-list types of mapping.
Chris@16 96 The three last parameters are used to specify the set type of
Chris@16 97 the relation, an inplace hooked data class and the allocator
Chris@16 98 type. As a help to the bimap user, these parameters support
Chris@16 99 default types but use a special idiom that allow them to be
Chris@16 100 specified without interleaving the usual use_default keyword.
Chris@16 101 The possible bimap instantiation are enumerated here:
Chris@16 102 \c {Side}KeyType can be directly a type, this is default to
Chris@16 103 \c set_of<{Side}KeyType>, or can be a \c {SetType}_of<Type>
Chris@16 104 specification. Additionally this two parameters can be tagged
Chris@16 105 to specify others tags instead of the usual \c member_at::{Side}
Chris@16 106 ones.
Chris@16 107
Chris@16 108
Chris@16 109 \code
Chris@16 110
Chris@16 111 typedef bimap
Chris@16 112 <
Chris@16 113 LeftCollectionType, RightCollectionType
Chris@16 114
Chris@16 115 [ , SetTypeOfRelation ] // Default to left_based
Chris@16 116 [ , info_hook< Info > ] // Default to no info
Chris@16 117 [ , Allocator ] // Default to std::allocator<>
Chris@16 118
Chris@16 119 > bm;
Chris@16 120
Chris@16 121 \endcode
Chris@16 122
Chris@16 123 **/
Chris@16 124
Chris@16 125
Chris@16 126 template
Chris@16 127 <
Chris@16 128 class KeyTypeA, class KeyTypeB,
Chris@16 129 class AP1 = ::boost::mpl::na,
Chris@16 130 class AP2 = ::boost::mpl::na,
Chris@16 131 class AP3 = ::boost::mpl::na
Chris@16 132 >
Chris@16 133 class bimap
Chris@16 134 :
Chris@16 135 // Bimap Core, use mpl magic to find the desired bimap type
Chris@16 136
Chris@16 137 public ::boost::bimaps::detail::bimap_core<KeyTypeA,KeyTypeB,AP1,AP2,AP3>,
Chris@16 138
Chris@16 139 // You can use bimap as a collection of relations
Chris@16 140
Chris@16 141 public ::boost::bimaps::detail::bimap_core<KeyTypeA,KeyTypeB,AP1,AP2,AP3>
Chris@16 142 ::relation_set,
Chris@16 143
Chris@16 144 // Include extra typedefs (i.e. left_local_iterator for unordered_map)
Chris@16 145
Chris@16 146 public ::boost::bimaps::detail:: left_map_view_extra_typedefs<
Chris@16 147 BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::left_map_view_type<
Chris@16 148 ::boost::bimaps::detail::bimap_core<KeyTypeA,KeyTypeB,AP1,AP2,AP3>
Chris@16 149 >::type
Chris@16 150 >,
Chris@16 151 public ::boost::bimaps::detail::right_map_view_extra_typedefs<
Chris@16 152 BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::right_map_view_type<
Chris@16 153 ::boost::bimaps::detail::bimap_core<KeyTypeA,KeyTypeB,AP1,AP2,AP3>
Chris@16 154 >::type
Chris@16 155 >
Chris@16 156 {
Chris@16 157 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::
Chris@16 158 bimap_core<KeyTypeA,KeyTypeB,AP1,AP2,AP3> base_;
Chris@16 159
Chris@16 160 BOOST_DEDUCED_TYPENAME base_::core_type core;
Chris@16 161
Chris@16 162 public:
Chris@16 163
Chris@16 164 // metadata --------------------------------------------------------
Chris@16 165
Chris@16 166 /*
Chris@16 167 // The rest is computed in the core, because it is quite difficult to
Chris@16 168 // expose a nice interface with so many metaprogramming stuff.
Chris@16 169
Chris@16 170 // Map by {side} metadata
Chris@16 171
Chris@16 172 typedef -unspecified- {side}_tag;
Chris@16 173 typedef -unspecified- {side}_data_type;
Chris@16 174 typedef -unspecified- {side}_value_type;
Chris@16 175 typedef -unspecified- {side}_key_type;
Chris@16 176
Chris@16 177 // There are other typedefs for definitions of different map views
Chris@16 178
Chris@16 179 ------------------------------------------------------------------*/
Chris@16 180
Chris@16 181 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::
Chris@16 182 left_map_view_type<base_>::type left_map;
Chris@16 183 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::
Chris@16 184 right_map_view_type<base_>::type right_map;
Chris@16 185
Chris@16 186 typedef BOOST_DEDUCED_TYPENAME
Chris@16 187 left_map::iterator left_iterator;
Chris@16 188 typedef BOOST_DEDUCED_TYPENAME
Chris@16 189 left_map::const_iterator left_const_iterator;
Chris@16 190
Chris@16 191 typedef BOOST_DEDUCED_TYPENAME
Chris@16 192 right_map::iterator right_iterator;
Chris@16 193 typedef BOOST_DEDUCED_TYPENAME
Chris@16 194 right_map::const_iterator right_const_iterator;
Chris@16 195
Chris@16 196 typedef BOOST_DEDUCED_TYPENAME
Chris@16 197 left_map::reference left_reference;
Chris@16 198 typedef BOOST_DEDUCED_TYPENAME
Chris@16 199 left_map::const_reference left_const_reference;
Chris@16 200
Chris@16 201 typedef BOOST_DEDUCED_TYPENAME
Chris@16 202 right_map::reference right_reference;
Chris@16 203 typedef BOOST_DEDUCED_TYPENAME
Chris@16 204 right_map::const_reference right_const_reference;
Chris@16 205
Chris@16 206 typedef BOOST_DEDUCED_TYPENAME base_::relation::info_type info_type;
Chris@16 207
Chris@16 208 typedef BOOST_DEDUCED_TYPENAME base_::core_type::allocator_type allocator_type;
Chris@16 209
Chris@16 210 /// Left map view
Chris@16 211 left_map left;
Chris@16 212
Chris@16 213 /// Right map view
Chris@16 214 right_map right;
Chris@16 215
Chris@16 216 typedef BOOST_DEDUCED_TYPENAME base_::logic_relation_set_tag
Chris@16 217 logic_relation_set_tag;
Chris@16 218 typedef BOOST_DEDUCED_TYPENAME base_::logic_left_tag logic_left_tag;
Chris@16 219 typedef BOOST_DEDUCED_TYPENAME base_::logic_right_tag logic_right_tag;
Chris@16 220 typedef BOOST_DEDUCED_TYPENAME base_::core_type::ctor_args_list
Chris@16 221 ctor_args_list;
Chris@16 222
Chris@16 223 bimap(const allocator_type& al = allocator_type()) :
Chris@16 224
Chris@16 225 base_::relation_set(
Chris@16 226 ::boost::multi_index::get<
Chris@16 227 logic_relation_set_tag
Chris@16 228 >(core)
Chris@16 229 ),
Chris@16 230
Chris@16 231 core(al),
Chris@16 232
Chris@16 233 left (
Chris@16 234 ::boost::multi_index::get<
Chris@16 235 logic_left_tag
Chris@16 236 >(core)
Chris@16 237 ),
Chris@16 238 right (
Chris@16 239 ::boost::multi_index::get<
Chris@16 240 logic_right_tag
Chris@16 241 >(core)
Chris@16 242 )
Chris@16 243
Chris@16 244 {}
Chris@16 245
Chris@16 246 template< class InputIterator >
Chris@16 247 bimap(InputIterator first,InputIterator last,
Chris@16 248 const allocator_type& al = allocator_type()) :
Chris@16 249
Chris@16 250 base_::relation_set(
Chris@16 251 ::boost::multi_index::get<
Chris@16 252 BOOST_DEDUCED_TYPENAME base_::logic_relation_set_tag>(core)
Chris@16 253 ),
Chris@16 254
Chris@16 255 core(first,last,ctor_args_list(),al),
Chris@16 256
Chris@16 257 left (
Chris@16 258 ::boost::multi_index::get<
Chris@16 259 BOOST_DEDUCED_TYPENAME base_::logic_left_tag>(core)
Chris@16 260 ),
Chris@16 261 right (
Chris@16 262 ::boost::multi_index::get<
Chris@16 263 BOOST_DEDUCED_TYPENAME base_::logic_right_tag>(core)
Chris@16 264 )
Chris@16 265
Chris@16 266 {}
Chris@16 267
Chris@16 268 bimap(const bimap& x) :
Chris@16 269
Chris@16 270 base_::relation_set(
Chris@16 271 ::boost::multi_index::get<
Chris@16 272 BOOST_DEDUCED_TYPENAME base_::logic_relation_set_tag>(core)
Chris@16 273 ),
Chris@16 274
Chris@16 275 core(x.core),
Chris@16 276
Chris@16 277 left (
Chris@16 278 ::boost::multi_index::get<
Chris@16 279 BOOST_DEDUCED_TYPENAME base_::logic_left_tag>(core)
Chris@16 280 ),
Chris@16 281 right (
Chris@16 282 ::boost::multi_index::get<
Chris@16 283 BOOST_DEDUCED_TYPENAME base_::logic_right_tag>(core)
Chris@16 284 )
Chris@16 285
Chris@16 286 {}
Chris@16 287
Chris@16 288 bimap& operator=(const bimap& x)
Chris@16 289 {
Chris@16 290 core = x.core;
Chris@16 291 return *this;
Chris@16 292 }
Chris@16 293
Chris@16 294 // Projection of iterators
Chris@16 295
Chris@16 296 template< class IteratorType >
Chris@16 297 left_iterator project_left(IteratorType iter)
Chris@16 298 {
Chris@16 299 return core.template project<
Chris@16 300 BOOST_DEDUCED_TYPENAME base_::logic_left_tag>(iter.base());
Chris@16 301 }
Chris@16 302
Chris@16 303 template< class IteratorType >
Chris@16 304 left_const_iterator project_left(IteratorType iter) const
Chris@16 305 {
Chris@16 306 return core.template project<
Chris@16 307 BOOST_DEDUCED_TYPENAME base_::logic_left_tag>(iter.base());
Chris@16 308 }
Chris@16 309
Chris@16 310 template< class IteratorType >
Chris@16 311 right_iterator project_right(IteratorType iter)
Chris@16 312 {
Chris@16 313 return core.template project<
Chris@16 314 BOOST_DEDUCED_TYPENAME base_::logic_right_tag>(iter.base());
Chris@16 315 }
Chris@16 316
Chris@16 317 template< class IteratorType >
Chris@16 318 right_const_iterator project_right(IteratorType iter) const
Chris@16 319 {
Chris@16 320 return core.template project<
Chris@16 321 BOOST_DEDUCED_TYPENAME base_::logic_right_tag>(iter.base());
Chris@16 322 }
Chris@16 323
Chris@16 324 template< class IteratorType >
Chris@16 325 BOOST_DEDUCED_TYPENAME base_::relation_set::iterator
Chris@16 326 project_up(IteratorType iter)
Chris@16 327 {
Chris@16 328 return core.template project<
Chris@16 329 BOOST_DEDUCED_TYPENAME base_::logic_relation_set_tag>(iter.base());
Chris@16 330 }
Chris@16 331
Chris@16 332 template< class IteratorType >
Chris@16 333 BOOST_DEDUCED_TYPENAME base_::relation_set::const_iterator
Chris@16 334 project_up(IteratorType iter) const
Chris@16 335 {
Chris@16 336 return core.template project<
Chris@16 337 BOOST_DEDUCED_TYPENAME base_::logic_relation_set_tag>(iter.base());
Chris@16 338 }
Chris@16 339
Chris@16 340 // Support for tags
Chris@16 341
Chris@16 342 template< class Tag, class IteratorType >
Chris@16 343 BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
Chris@16 344 iterator_type_by<Tag,bimap>::type
Chris@101 345 project(IteratorType iter)
Chris@16 346 {
Chris@16 347 return core.template project<Tag>(iter.base());
Chris@16 348 }
Chris@16 349
Chris@16 350 template< class Tag, class IteratorType >
Chris@16 351 BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
Chris@16 352 const_iterator_type_by<Tag,bimap>::type
Chris@101 353 project(IteratorType iter) const
Chris@16 354 {
Chris@16 355 return core.template project<Tag>(iter.base());
Chris@16 356 }
Chris@16 357
Chris@16 358 template< class Tag >
Chris@16 359 struct map_by :
Chris@16 360 public ::boost::bimaps::support::map_type_by<Tag,bimap>::type
Chris@16 361 {
Chris@16 362 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
Chris@16 363 map_type_by<Tag,bimap>::type type;
Chris@16 364
Chris@16 365 private: map_by() {}
Chris@16 366 };
Chris@16 367
Chris@16 368 template< class Tag >
Chris@16 369 BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
Chris@101 370 map_type_by<Tag,bimap>::type &by()
Chris@16 371 {
Chris@16 372 return ::boost::bimaps::support::map_by<Tag>(*this);
Chris@16 373 }
Chris@16 374
Chris@16 375 template< class Tag >
Chris@16 376 const BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
Chris@101 377 map_type_by<Tag,bimap>::type &by() const
Chris@16 378 {
Chris@16 379 return ::boost::bimaps::support::map_by<Tag>(*this);
Chris@16 380 }
Chris@16 381
Chris@16 382
Chris@16 383 #ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
Chris@16 384
Chris@16 385 // Serialization support
Chris@16 386
Chris@16 387 private:
Chris@16 388
Chris@16 389 friend class boost::serialization::access;
Chris@16 390
Chris@16 391 template<class Archive>
Chris@16 392 void serialize(Archive & ar, const unsigned int)
Chris@16 393 {
Chris@16 394 ar & serialization::make_nvp("mi_core",core);
Chris@16 395 }
Chris@16 396
Chris@16 397 #endif // BOOST_BIMAP_DISABLE_SERIALIZATION
Chris@16 398 };
Chris@16 399
Chris@16 400 } // namespace bimaps
Chris@16 401 } // namespace boost
Chris@16 402
Chris@16 403
Chris@16 404 /** \namespace boost::bimaps::support
Chris@16 405 \brief Metafunctions to help working with bimaps.
Chris@16 406 **/
Chris@16 407
Chris@16 408 /** \namespace boost::bimaps::views
Chris@16 409 \brief Bimap views.
Chris@16 410 **/
Chris@16 411
Chris@16 412 /** \namespace boost::bimaps::views::detail
Chris@16 413 \brief Bimap views details.
Chris@16 414 **/
Chris@16 415
Chris@16 416
Chris@16 417
Chris@16 418 // Include basic tools for user commodity
Chris@16 419
Chris@16 420 #include <boost/bimap/tags/tagged.hpp>
Chris@16 421 #include <boost/bimap/relation/member_at.hpp>
Chris@16 422 #include <boost/multi_index/detail/unbounded.hpp>
Chris@16 423
Chris@16 424 // Bring the most used namespaces directly to the user main namespace
Chris@16 425 namespace boost {
Chris@16 426 namespace bimaps {
Chris@16 427
Chris@16 428 using ::boost::bimaps::tags::tagged;
Chris@16 429
Chris@16 430 namespace member_at = ::boost::bimaps::relation::member_at;
Chris@16 431
Chris@16 432 using ::boost::multi_index::unbounded;
Chris@16 433
Chris@16 434 } // namespace bimaps
Chris@16 435 } // namespace boost
Chris@16 436
Chris@16 437
Chris@16 438 #endif // BOOST_BIMAP_BIMAP_HPP