├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── .travis.yml ├── CMakeLists.txt ├── build.jam ├── doc ├── acknowledgements.qbk ├── bimap.hdf ├── bimap.qbk ├── bimap_and_boost.qbk ├── compiler_specifics.qbk ├── directdoxygen.jam ├── examples.qbk ├── future_work.qbk ├── history.qbk ├── html │ ├── boost_bimap │ │ ├── acknowledgements.html │ │ ├── bimap_and_boost.html │ │ ├── bimap_and_boost │ │ │ ├── boost_libraries_that_work_well_with_boost_bimap.html │ │ │ └── dependencies.html │ │ ├── compiler_specifics.html │ │ ├── examples.html │ │ ├── examples │ │ │ ├── mighty_bimap.html │ │ │ ├── multiindex_to_bimap_path___bidirectional_map.html │ │ │ ├── multiindex_to_bimap_path___hashed_indices.html │ │ │ └── simple_bimap.html │ │ ├── future_work.html │ │ ├── history.html │ │ ├── history │ │ │ └── multiindex_and_bimap.html │ │ ├── introduction.html │ │ ├── one_minute_tutorial.html │ │ ├── performance.html │ │ ├── rationale.html │ │ ├── rationale │ │ │ ├── additional_features.html │ │ │ ├── code.html │ │ │ └── the_student_and_the_mentor.html │ │ ├── reference.html │ │ ├── reference │ │ │ ├── bimap_reference.html │ │ │ ├── list_of_reference.html │ │ │ ├── set_of_reference.html │ │ │ ├── unconstrained_set_of_reference.html │ │ │ ├── unordered_set_of_reference.html │ │ │ └── vector_of_reference.html │ │ ├── release_notes.html │ │ ├── test_suite.html │ │ ├── the_tutorial.html │ │ └── the_tutorial │ │ │ ├── additional_information.html │ │ │ ├── bimaps_with_user_defined_names.html │ │ │ ├── complete_instantiation_scheme.html │ │ │ ├── controlling_collection_types.html │ │ │ ├── differences_with_standard_maps.html │ │ │ ├── discovering_the_bimap_framework.html │ │ │ ├── the_collection_of_relations_type.html │ │ │ ├── unconstrained_sets.html │ │ │ └── useful_functions.html │ ├── boostbook.css │ ├── images │ │ ├── bimap │ │ │ ├── bimap.structures.png │ │ │ ├── boost.bimap.header.png │ │ │ ├── boost.bimap.logo.png │ │ │ ├── collection.type.of.relation.png │ │ │ ├── extended.mapping.framework.png │ │ │ ├── miBimapFramework.png │ │ │ ├── more.bimap.structures.png │ │ │ ├── relation.and.pair.png │ │ │ ├── relation.and.pair.with.info.png │ │ │ ├── relation.png │ │ │ ├── simple.bimap.png │ │ │ ├── standard.mapping.framework.png │ │ │ └── tagged.png │ │ ├── callouts │ │ │ ├── 1.png │ │ │ ├── 10.png │ │ │ ├── 11.png │ │ │ ├── 12.png │ │ │ ├── 13.png │ │ │ ├── 14.png │ │ │ ├── 15.png │ │ │ ├── 2.png │ │ │ ├── 3.png │ │ │ ├── 4.png │ │ │ ├── 5.png │ │ │ ├── 6.png │ │ │ ├── 7.png │ │ │ ├── 8.png │ │ │ └── 9.png │ │ ├── extern │ │ │ └── googlesoc.png │ │ ├── people │ │ │ ├── hector.png │ │ │ ├── joaquin.png │ │ │ ├── mafalda.png │ │ │ └── matias.png │ │ └── space.png │ ├── index.html │ └── standalone_HTML.manifest ├── introduction.qbk ├── jamfile.v2 ├── performance.qbk ├── quick_tutorial.qbk ├── rationale.qbk ├── reference.qbk ├── reference │ ├── bimap.qbk │ ├── list_of.qbk │ ├── set_of.qbk │ ├── unconstrained_set_of.qbk │ ├── unordered_set_of.qbk │ └── vector_of.qbk ├── release_notes.qbk ├── test_suite.qbk ├── toolbox.qbk └── tutorial.qbk ├── example ├── Jamfile.v2 ├── at_function_examples.cpp ├── bimap_and_boost │ ├── assign.cpp │ ├── foreach.cpp │ ├── lambda.cpp │ ├── property_map.cpp │ ├── range.cpp │ ├── serialization.cpp │ ├── typeof.cpp │ └── xpressive.cpp ├── mi_to_b_path │ ├── bidirectional_map.cpp │ ├── hashed_indices.cpp │ ├── mi_bidirectional_map.cpp │ ├── mi_hashed_indices.cpp │ └── tagged_bidirectional_map.cpp ├── mighty_bimap.cpp ├── population_bimap.cpp ├── projection.cpp ├── repetitions_counter.cpp ├── simple_bimap.cpp ├── standard_map_comparison.cpp ├── step_by_step.cpp ├── tagged_simple_bimap.cpp ├── tutorial_info_hook.cpp ├── tutorial_modify_and_replace.cpp ├── tutorial_range.cpp ├── unconstrained_collection.cpp └── user_defined_names.cpp ├── include └── boost │ ├── bimap.hpp │ └── bimap │ ├── bimap.hpp │ ├── container_adaptor │ ├── associative_container_adaptor.hpp │ ├── container_adaptor.hpp │ ├── detail │ │ ├── comparison_adaptor.hpp │ │ ├── functor_bag.hpp │ │ ├── identity_converters.hpp │ │ ├── key_extractor.hpp │ │ └── non_unique_container_helper.hpp │ ├── list_adaptor.hpp │ ├── list_map_adaptor.hpp │ ├── map_adaptor.hpp │ ├── multimap_adaptor.hpp │ ├── multiset_adaptor.hpp │ ├── ordered_associative_container_adaptor.hpp │ ├── sequence_container_adaptor.hpp │ ├── set_adaptor.hpp │ ├── support │ │ └── iterator_facade_converters.hpp │ ├── unordered_associative_container_adaptor.hpp │ ├── unordered_map_adaptor.hpp │ ├── unordered_multimap_adaptor.hpp │ ├── unordered_multiset_adaptor.hpp │ ├── unordered_set_adaptor.hpp │ ├── vector_adaptor.hpp │ └── vector_map_adaptor.hpp │ ├── detail │ ├── bimap_core.hpp │ ├── concept_tags.hpp │ ├── debug │ │ └── static_error.hpp │ ├── generate_index_binder.hpp │ ├── generate_relation_binder.hpp │ ├── generate_view_binder.hpp │ ├── is_set_type_of.hpp │ ├── manage_additional_parameters.hpp │ ├── manage_bimap_key.hpp │ ├── map_view_base.hpp │ ├── map_view_iterator.hpp │ ├── modifier_adaptor.hpp │ ├── non_unique_views_helper.hpp │ ├── set_view_base.hpp │ ├── set_view_iterator.hpp │ ├── test │ │ └── check_metadata.hpp │ └── user_interface_config.hpp │ ├── list_of.hpp │ ├── multiset_of.hpp │ ├── property_map │ ├── set_support.hpp │ └── unordered_set_support.hpp │ ├── relation │ ├── detail │ │ ├── access_builder.hpp │ │ ├── metadata_access_builder.hpp │ │ ├── mutant.hpp │ │ ├── static_access_builder.hpp │ │ └── to_mutable_relation_functor.hpp │ ├── member_at.hpp │ ├── mutant_relation.hpp │ ├── pair_layout.hpp │ ├── structured_pair.hpp │ ├── support │ │ ├── data_extractor.hpp │ │ ├── get.hpp │ │ ├── get_pair_functor.hpp │ │ ├── is_tag_of_member_at.hpp │ │ ├── member_with_tag.hpp │ │ ├── opposite_tag.hpp │ │ ├── pair_by.hpp │ │ ├── pair_type_by.hpp │ │ └── value_type_of.hpp │ └── symmetrical_base.hpp │ ├── set_of.hpp │ ├── support │ ├── data_type_by.hpp │ ├── iterator_type_by.hpp │ ├── key_type_by.hpp │ ├── lambda.hpp │ ├── map_by.hpp │ ├── map_type_by.hpp │ └── value_type_by.hpp │ ├── tags │ ├── support │ │ ├── apply_to_value_type.hpp │ │ ├── default_tagged.hpp │ │ ├── is_tagged.hpp │ │ ├── overwrite_tagged.hpp │ │ ├── tag_of.hpp │ │ └── value_type_of.hpp │ └── tagged.hpp │ ├── unconstrained_set_of.hpp │ ├── unordered_multiset_of.hpp │ ├── unordered_set_of.hpp │ ├── vector_of.hpp │ └── views │ ├── list_map_view.hpp │ ├── list_set_view.hpp │ ├── map_view.hpp │ ├── multimap_view.hpp │ ├── multiset_view.hpp │ ├── set_view.hpp │ ├── unconstrained_map_view.hpp │ ├── unconstrained_set_view.hpp │ ├── unordered_map_view.hpp │ ├── unordered_multimap_view.hpp │ ├── unordered_multiset_view.hpp │ ├── unordered_set_view.hpp │ ├── vector_map_view.hpp │ └── vector_set_view.hpp ├── index.html ├── meta └── libraries.json └── test ├── Jamfile.v2 ├── compile_fail ├── test_bimap_info_1.cpp ├── test_bimap_info_2.cpp ├── test_bimap_info_3.cpp ├── test_bimap_mutable_1.cpp ├── test_bimap_mutable_2.cpp └── test_bimap_mutable_3.cpp ├── strong_type.hpp ├── test_bimap.hpp ├── test_bimap_assign.cpp ├── test_bimap_convenience_header.cpp ├── test_bimap_extra.cpp ├── test_bimap_info.cpp ├── test_bimap_lambda.cpp ├── test_bimap_list_of.cpp ├── test_bimap_modify.cpp ├── test_bimap_multiset_of.cpp ├── test_bimap_mutable.cpp ├── test_bimap_operator_bracket.cpp ├── test_bimap_ordered.cpp ├── test_bimap_project.cpp ├── test_bimap_property_map.cpp ├── test_bimap_range.cpp ├── test_bimap_sequenced.cpp ├── test_bimap_serialization.cpp ├── test_bimap_set_of.cpp ├── test_bimap_unconstrained.cpp ├── test_bimap_unordered.cpp ├── test_bimap_unordered_multiset_of.cpp ├── test_bimap_unordered_set_of.cpp ├── test_bimap_vector_of.cpp ├── test_mutant.cpp ├── test_mutant_relation.cpp ├── test_relation.hpp ├── test_structured_pair.cpp └── test_tagged.cpp /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Generated by `boostdep --cmake bimap` 2 | # Copyright 2020, 2021 Peter Dimov 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # https://www.boost.org/LICENSE_1_0.txt 5 | 6 | cmake_minimum_required(VERSION 3.5...3.20) 7 | 8 | project(boost_bimap VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) 9 | 10 | add_library(boost_bimap INTERFACE) 11 | add_library(Boost::bimap ALIAS boost_bimap) 12 | 13 | target_include_directories(boost_bimap INTERFACE include) 14 | 15 | target_link_libraries(boost_bimap 16 | INTERFACE 17 | Boost::concept_check 18 | Boost::config 19 | Boost::container_hash 20 | Boost::core 21 | Boost::iterator 22 | Boost::lambda 23 | Boost::mpl 24 | Boost::multi_index 25 | Boost::preprocessor 26 | Boost::static_assert 27 | Boost::throw_exception 28 | Boost::type_traits 29 | Boost::utility 30 | ) 31 | 32 | if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") 33 | 34 | add_subdirectory(test) 35 | 36 | endif() 37 | -------------------------------------------------------------------------------- /build.jam: -------------------------------------------------------------------------------- 1 | # Copyright René Ferdinand Rivera Morell 2023-2024 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | require-b2 5.2 ; 7 | 8 | constant boost_dependencies : 9 | /boost/concept_check//boost_concept_check 10 | /boost/config//boost_config 11 | /boost/container_hash//boost_container_hash 12 | /boost/core//boost_core 13 | /boost/iterator//boost_iterator 14 | /boost/lambda//boost_lambda 15 | /boost/mpl//boost_mpl 16 | /boost/multi_index//boost_multi_index 17 | /boost/preprocessor//boost_preprocessor 18 | /boost/static_assert//boost_static_assert 19 | /boost/throw_exception//boost_throw_exception 20 | /boost/type_traits//boost_type_traits 21 | /boost/utility//boost_utility ; 22 | 23 | project /boost/bimap ; 24 | 25 | explicit 26 | [ alias boost_bimap : : : : include $(boost_dependencies) ] 27 | [ alias all : boost_bimap example test ] 28 | ; 29 | 30 | call-if : boost-library bimap 31 | ; 32 | -------------------------------------------------------------------------------- /doc/acknowledgements.qbk: -------------------------------------------------------------------------------- 1 | [/license 2 | 3 | Boost.Bimap 4 | 5 | Copyright (c) 2006-2007 Matias Capeletto 6 | 7 | Distributed under the Boost Software License, Version 1.0. 8 | (See accompanying file LICENSE_1_0.txt or copy at 9 | http://www.boost.org/LICENSE_1_0.txt) 10 | 11 | ] 12 | 13 | [/ QuickBook Document version 1.4 ] 14 | 15 | [section Acknowledgements] 16 | 17 | This library was developed in the context of the Google SoC 2006. I 18 | first want to thank my mentor, Joaquin, for his friendship during this 19 | project. Not only did he help me go through the process of creating this 20 | library, but he also did his best so we could have a great time doing 21 | it. Also, Boost.Bimap would not exist had Boost.MultiIndex, Joaquin's 22 | masterpiece, not existed. Thanks a lot! 23 | 24 | __GOOGLE_SOC_2006__ 25 | 26 | I want to thank Google for this amazing ['boost] to the open-source 27 | community and to Boost mentors for trusting in my proposal in the first 28 | place. Next on the list are my colleagues from SoC that helped me not 29 | get bored during the long hours of coding. 30 | 31 | Special acknowledgements to the developers of the Boost libraries that 32 | Boost.Bimap has abused. See the dependencies section for a complete list. 33 | 34 | I want to thank the open-source developers who wrote the tools I used 35 | during this project. The list of names is infinitely long, so I 36 | give a general huge thanks here. 37 | 38 | Thanks to Paul Giaccone for proof-reading this documentation. (He has 39 | not finished yet -- the remaining typos and spelling errors are mine and 40 | will be corrected as soon as possible.) 41 | 42 | Finally, thanks to my family, who had to see me at home all day during 43 | the SoC. Special thanks to my brother Agustin, future famous novelist 44 | (at the present time he is 19 years old), who patiently read every word 45 | of these docs and while correcting them, barked at me for my bad written 46 | English. I have learned a lot from his sermons. I want to thank my dog, 47 | Mafalda, too for barking all day from my window and for being such a 48 | good company. 49 | 50 | Thanks to Alisdair Meredith, Fernando Cacciola, Jeff Garland, John Maddock, 51 | Thorsten Ottosen, Tony and Giovanni Piero Deretta for participating in 52 | the formal review and give me useful advices to improve this library. 53 | And thanks a lot to Ion Gaztañaga for managing the review. 54 | 55 | [heading Boost.Bimap Team] 56 | 57 | From Argentina... Matias and Mafalda and from Spain... Joaquin and Hector 58 | 59 | __MATIAS_PHOTO__ 60 | __MAFALDA_PHOTO__ 61 | __JOAQUIN_PHOTO__ 62 | __HECTOR_PHOTO__ 63 | 64 | Luckily, the distance helps team members avoid eating each other. 65 | 66 | [endsect] -------------------------------------------------------------------------------- /doc/compiler_specifics.qbk: -------------------------------------------------------------------------------- 1 | [/license 2 | 3 | Boost.Bimap 4 | 5 | Copyright (c) 2006-2007 Matias Capeletto 6 | 7 | Distributed under the Boost Software License, Version 1.0. 8 | (See accompanying file LICENSE_1_0.txt or copy at 9 | http://www.boost.org/LICENSE_1_0.txt) 10 | 11 | ] 12 | 13 | [/ QuickBook Document version 1.4 ] 14 | 15 | [section Compiler specifics] 16 | 17 | [table 18 | [[Compiler ][OS Tested ][State ]] 19 | [[GCC 3.3 ][Linux ][Supported ]] 20 | [[GCC 3.4 ][Linux ][Supported ]] 21 | [[GCC 4.0 ][Linux, Mac][Supported ]] 22 | [[GCC 4.1 ][Linux ][Supported ]] 23 | [[GCC 4.2 ][Linux ][Supported ]] 24 | [[ICC 8.0 ][Linux ][Supported ]] 25 | [[ICC 9.0 ][Linux ][Supported ]] 26 | [[ICC 9.1 ][Linux ][Supported ]] 27 | [[GCC 4.2 ][Linux ][Supported ]] 28 | [[GCC 4.2 ][Linux ][Supported ]] 29 | [[VS 7.1 ][Windows ][Supported ]] 30 | [[VS 8.0 ][Windows ][Supported ]] 31 | [[ICC 7.1 ][Windows ][Not Supported ]] 32 | [[ICC 8.0 ][Windows ][Supported ]] 33 | [[ICC 9.1 ][Windows ][Supported ]] 34 | [[CW 8.3 ][Windows ][Not Supported ]] 35 | ] 36 | 37 | [/ 38 | [[Comeau C++][ ][Not yet tested (Will be supported) ]] 39 | [[CW 8.3 ][Windows ][On going effort to support it ]] 40 | ] 41 | 42 | [h2 VS 7.1] 43 | 44 | If a .cpp file uses more than four different bimaps the compiler will run 45 | out of symbols and issue an internal compiler error. The official solution 46 | in msdn is to split the .cpp in several files or upgrade your compiler. 47 | 48 | [h2 VS 8.0] 49 | 50 | VC++ 8.0 warns on usage of certain Standard Library and API functions that 51 | can be cause buffer overruns or other possible security issues if misused. 52 | See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 53 | But the wording of the warning is misleading and unsettling, there are no 54 | portable alternative functions, and VC++ 8.0's own libraries use the 55 | functions in question. In order to turn off the warnings add the following 56 | defines at the begging of your .cpp files: 57 | 58 | #define _CRT_SECURE_NO_DEPRECATE 59 | #define _SCL_SECURE_NO_DEPRECATE 60 | 61 | [endsect] -------------------------------------------------------------------------------- /doc/directdoxygen.jam: -------------------------------------------------------------------------------- 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 | 10 | import type ; 11 | import generators ; 12 | 13 | type.register HTML_DOXYFILE : hdf ; 14 | type.register HTML_DOXYDOCS : hdt ; 15 | 16 | generators.register-standard directdoxygen.run : HTML_DOXYFILE : HTML_DOXYDOCS ; 17 | 18 | actions run 19 | { 20 | "doxygen" $(>) 21 | echo "Stamped" > "$(<)" 22 | } 23 | -------------------------------------------------------------------------------- /doc/future_work.qbk: -------------------------------------------------------------------------------- 1 | [/license 2 | 3 | Boost.Bimap 4 | 5 | Copyright (c) 2006-2007 Matias Capeletto 6 | 7 | Distributed under the Boost Software License, Version 1.0. 8 | (See accompanying file LICENSE_1_0.txt or copy at 9 | http://www.boost.org/LICENSE_1_0.txt) 10 | 11 | ] 12 | 13 | [/ QuickBook Document version 1.4 ] 14 | 15 | [section Future work] 16 | 17 | 18 | [heading Rearrange Function] 19 | 20 | Boost.MultiIndex includes some others functions that can be included in the views. 21 | 22 | 23 | [endsect] -------------------------------------------------------------------------------- /doc/html/boost_bimap/future_work.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Future work 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |

27 | Future work 28 |

29 |

30 | 31 | Rearrange 32 | Function 33 |

34 |

35 | Boost.MultiIndex includes some others functions that can be included in the 36 | views. 37 |

38 |
39 | 40 | 41 | 46 |
47 |
48 |
49 | PrevUpHomeNext 50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /doc/html/boost_bimap/performance.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Performance 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
21 |
22 |
23 | PrevUpHomeNext 24 |
25 |
26 |

27 | Performance 28 |

29 |

30 | Section under construction. 31 |

32 |
33 | 34 | 35 | 40 |
41 |
42 |
43 | PrevUpHomeNext 44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /doc/html/images/bimap/bimap.structures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/bimap.structures.png -------------------------------------------------------------------------------- /doc/html/images/bimap/boost.bimap.header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/boost.bimap.header.png -------------------------------------------------------------------------------- /doc/html/images/bimap/boost.bimap.logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/boost.bimap.logo.png -------------------------------------------------------------------------------- /doc/html/images/bimap/collection.type.of.relation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/collection.type.of.relation.png -------------------------------------------------------------------------------- /doc/html/images/bimap/extended.mapping.framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/extended.mapping.framework.png -------------------------------------------------------------------------------- /doc/html/images/bimap/miBimapFramework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/miBimapFramework.png -------------------------------------------------------------------------------- /doc/html/images/bimap/more.bimap.structures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/more.bimap.structures.png -------------------------------------------------------------------------------- /doc/html/images/bimap/relation.and.pair.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/relation.and.pair.png -------------------------------------------------------------------------------- /doc/html/images/bimap/relation.and.pair.with.info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/relation.and.pair.with.info.png -------------------------------------------------------------------------------- /doc/html/images/bimap/relation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/relation.png -------------------------------------------------------------------------------- /doc/html/images/bimap/simple.bimap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/simple.bimap.png -------------------------------------------------------------------------------- /doc/html/images/bimap/standard.mapping.framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/standard.mapping.framework.png -------------------------------------------------------------------------------- /doc/html/images/bimap/tagged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/bimap/tagged.png -------------------------------------------------------------------------------- /doc/html/images/callouts/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/1.png -------------------------------------------------------------------------------- /doc/html/images/callouts/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/10.png -------------------------------------------------------------------------------- /doc/html/images/callouts/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/11.png -------------------------------------------------------------------------------- /doc/html/images/callouts/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/12.png -------------------------------------------------------------------------------- /doc/html/images/callouts/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/13.png -------------------------------------------------------------------------------- /doc/html/images/callouts/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/14.png -------------------------------------------------------------------------------- /doc/html/images/callouts/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/15.png -------------------------------------------------------------------------------- /doc/html/images/callouts/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/2.png -------------------------------------------------------------------------------- /doc/html/images/callouts/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/3.png -------------------------------------------------------------------------------- /doc/html/images/callouts/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/4.png -------------------------------------------------------------------------------- /doc/html/images/callouts/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/5.png -------------------------------------------------------------------------------- /doc/html/images/callouts/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/6.png -------------------------------------------------------------------------------- /doc/html/images/callouts/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/7.png -------------------------------------------------------------------------------- /doc/html/images/callouts/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/8.png -------------------------------------------------------------------------------- /doc/html/images/callouts/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/callouts/9.png -------------------------------------------------------------------------------- /doc/html/images/extern/googlesoc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/extern/googlesoc.png -------------------------------------------------------------------------------- /doc/html/images/people/hector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/people/hector.png -------------------------------------------------------------------------------- /doc/html/images/people/joaquin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/people/joaquin.png -------------------------------------------------------------------------------- /doc/html/images/people/mafalda.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/people/mafalda.png -------------------------------------------------------------------------------- /doc/html/images/people/matias.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/people/matias.png -------------------------------------------------------------------------------- /doc/html/images/space.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/bimap/f64de6d045bf6aa3f39a672604bcccbc97291525/doc/html/images/space.png -------------------------------------------------------------------------------- /doc/html/standalone_HTML.manifest: -------------------------------------------------------------------------------- 1 | index.html 2 | boost_bimap/introduction.html 3 | boost_bimap/one_minute_tutorial.html 4 | boost_bimap/the_tutorial.html 5 | boost_bimap/the_tutorial/discovering_the_bimap_framework.html 6 | boost_bimap/the_tutorial/controlling_collection_types.html 7 | boost_bimap/the_tutorial/the_collection_of_relations_type.html 8 | boost_bimap/the_tutorial/differences_with_standard_maps.html 9 | boost_bimap/the_tutorial/useful_functions.html 10 | boost_bimap/the_tutorial/bimaps_with_user_defined_names.html 11 | boost_bimap/the_tutorial/unconstrained_sets.html 12 | boost_bimap/the_tutorial/additional_information.html 13 | boost_bimap/the_tutorial/complete_instantiation_scheme.html 14 | boost_bimap/bimap_and_boost.html 15 | boost_bimap/bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html 16 | boost_bimap/bimap_and_boost/dependencies.html 17 | boost_bimap/reference.html 18 | boost_bimap/reference/bimap_reference.html 19 | boost_bimap/reference/set_of_reference.html 20 | boost_bimap/reference/unordered_set_of_reference.html 21 | boost_bimap/reference/list_of_reference.html 22 | boost_bimap/reference/vector_of_reference.html 23 | boost_bimap/reference/unconstrained_set_of_reference.html 24 | boost_bimap/compiler_specifics.html 25 | boost_bimap/performance.html 26 | boost_bimap/examples.html 27 | boost_bimap/examples/simple_bimap.html 28 | boost_bimap/examples/mighty_bimap.html 29 | boost_bimap/examples/multiindex_to_bimap_path___bidirectional_map.html 30 | boost_bimap/examples/multiindex_to_bimap_path___hashed_indices.html 31 | boost_bimap/test_suite.html 32 | boost_bimap/future_work.html 33 | boost_bimap/release_notes.html 34 | boost_bimap/rationale.html 35 | boost_bimap/rationale/additional_features.html 36 | boost_bimap/rationale/code.html 37 | boost_bimap/rationale/the_student_and_the_mentor.html 38 | boost_bimap/history.html 39 | boost_bimap/history/multiindex_and_bimap.html 40 | boost_bimap/acknowledgements.html 41 | -------------------------------------------------------------------------------- /doc/jamfile.v2: -------------------------------------------------------------------------------- 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 | 10 | # Quickbook 11 | # ----------------------------------------------------------------------------- 12 | 13 | import quickbook ; 14 | 15 | xml bimap 16 | : 17 | bimap.qbk 18 | ; 19 | 20 | path-constant images_location : html ; 21 | 22 | boostbook standalone 23 | : 24 | bimap 25 | : 26 | boost.root=../../../.. 27 | html.stylesheet=boostbook.css 28 | toc.max.depth=2 29 | toc.section.depth=4 30 | chunk.section.depth=2 31 | pdf:img.src.path=$(images_location)/ 32 | pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/libs/bimap/doc/html 33 | ; 34 | 35 | 36 | # Doxygen 37 | # ----------------------------------------------------------------------------- 38 | # This generate the doxydocs and write "bimap.hdt". 39 | # Delete this file if you want to regenerate the doxydocs again 40 | # import directdoxygen ; 41 | # html-doxydocs bimap.hdt : bimap.hdf ; 42 | 43 | ############################################################################### 44 | alias boostdoc ; 45 | explicit boostdoc ; 46 | alias boostrelease : standalone ; 47 | explicit boostrelease ; 48 | -------------------------------------------------------------------------------- /doc/performance.qbk: -------------------------------------------------------------------------------- 1 | [/license 2 | 3 | Boost.Bimap 4 | 5 | Copyright (c) 2006-2007 Matias Capeletto 6 | 7 | Distributed under the Boost Software License, Version 1.0. 8 | (See accompanying file LICENSE_1_0.txt or copy at 9 | http://www.boost.org/LICENSE_1_0.txt) 10 | 11 | ] 12 | 13 | [/ QuickBook Document version 1.4 ] 14 | 15 | [section Performance] 16 | 17 | Section under construction. 18 | 19 | [endsect] -------------------------------------------------------------------------------- /doc/reference.qbk: -------------------------------------------------------------------------------- 1 | [/license 2 | 3 | Boost.Bimap 4 | 5 | Copyright (c) 2006-2007 Matias Capeletto 6 | 7 | Distributed under the Boost Software License, Version 1.0. 8 | (See accompanying file LICENSE_1_0.txt or copy at 9 | http://www.boost.org/LICENSE_1_0.txt) 10 | 11 | ] 12 | 13 | [/ QuickBook Document version 1.4 ] 14 | 15 | [section Reference] 16 | 17 | [section Headers] 18 | 19 | The following are the interface headers of Boost.Bimap: 20 | 21 | [*Convenience] 22 | 23 | * "boost/bimap.hpp" ['(includes "boost/bimap/bimap.hpp" and imports the bimap class to boost namespace)] 24 | 25 | [*Container] 26 | 27 | * "boost/bimap/bimap.hpp" ['(includes "boost/bimap/set_of.hpp" and "boost/bimap/unconstrained_set_of.hpp")] 28 | 29 | [*Set Types] 30 | 31 | * "boost/bimap/set_of.hpp" 32 | * "boost/bimap/multiset_of.hpp" 33 | * "boost/bimap/unordered_set_of.hpp" 34 | * "boost/bimap/unordered_multiset_of.hpp" 35 | * "boost/bimap/list_of.hpp" 36 | * "boost/bimap/vector_of.hpp" 37 | * "boost/bimap/unconstrained_set_of.hpp" 38 | 39 | [*Boost Integration] 40 | 41 | * "boost/bimap/support/lambda.hpp" 42 | * "boost/bimap/property_map/set_support.hpp" 43 | * "boost/bimap/property_map/unordered_set_support.hpp" 44 | 45 | A program using Boost.Bimap must therefore include 46 | "boost/bimap/bimap.hpp" and the headers defining the collection types to be used. 47 | 48 | Additional headers allow the integration of Boost.Bimap with other boost libraries, 49 | like Boost.Lambda and Boost.Property_map. 50 | 51 | In order to use the serialization capabilities of Boost.Bimap, the appropriate 52 | Boost.Serialization library module must be linked. Other than that, Boost.Bimap 53 | is a header-only library, requiring no additional object modules. 54 | 55 | [endsect] 56 | 57 | [include reference/bimap.qbk] 58 | [include reference/set_of.qbk] 59 | [include reference/unordered_set_of.qbk] 60 | [include reference/list_of.qbk] 61 | [include reference/vector_of.qbk] 62 | [include reference/unconstrained_set_of.qbk] 63 | 64 | [endsect] -------------------------------------------------------------------------------- /doc/release_notes.qbk: -------------------------------------------------------------------------------- 1 | [/license 2 | 3 | Boost.Bimap 4 | 5 | Copyright (c) 2006-2007 Matias Capeletto 6 | 7 | Distributed under the Boost Software License, Version 1.0. 8 | (See accompanying file LICENSE_1_0.txt or copy at 9 | http://www.boost.org/LICENSE_1_0.txt) 10 | 11 | ] 12 | 13 | [/ QuickBook Document version 1.4 ] 14 | 15 | [section Release notes] 16 | 17 | [heading Boost 1.85 release] 18 | 19 | * Fixed heterogeneous lookup for side collections ([@https://github.com/boostorg/bimap/pull/42 PR#42]). 20 | 21 | [heading Boost 1.53 release] 22 | 23 | * Refactor map_view_iterator to improve error messages. 24 | * Fixed replace_(left/right/key/data) bug when using relations with info. 25 | * Fixed vector_of and list_of views `assign(size_type,value_type)` bug. 26 | * Fixed vector_of views `operator[](size_type)` and `at(size_type)` functions return value. 27 | 28 | [heading Boost 1.52 release] 29 | 30 | * Fixed unused parameter name warnings in Boost.Bimap ([@https://svn.boost.org/trac/boost/ticket/7425 #7425]). 31 | 32 | [heading Boost 1.50 release] 33 | 34 | * Added key_type and mapped_type (leaving data_type for backward compatibility) typedefs to map views ([@https://svn.boost.org/trac/boost/ticket/6031 #6031]). 35 | * Removed spurious dependency on Boost.Serialization ([@https://svn.boost.org/trac/boost/ticket/3868 #3868]). 36 | * Solved unused constructor parameter warning ([@https://svn.boost.org/trac/boost/ticket/5749 #5749]). 37 | 38 | [heading Boost 1.45 release] 39 | * Fixed custom allocators ([@https://svn.boost.org/trac/boost/ticket/3665 #3665]). 40 | * Fixed count() constness ([@https://svn.boost.org/trac/boost/ticket/2484 #2484]). 41 | * Other maintenance fixes. 42 | 43 | [heading Boost 1.35 release] 44 | * Added to Boost Libraries. 45 | 46 | [endsect] -------------------------------------------------------------------------------- /doc/toolbox.qbk: -------------------------------------------------------------------------------- 1 | [/license 2 | 3 | Boost.Bimap 4 | 5 | Copyright (c) 2006-2007 Matias Capeletto 6 | 7 | Distributed under the Boost Software License, Version 1.0. 8 | (See accompanying file LICENSE_1_0.txt or copy at 9 | http://www.boost.org/LICENSE_1_0.txt) 10 | 11 | ] 12 | 13 | [/ QuickBook Document version 1.4 ] 14 | 15 | [section Bimap Toolbox] 16 | 17 | [section Mutant] 18 | 19 | [tip 20 | A mutant class defines storage compatible views in its declaration. 21 | You can the use the mutate(m) function to get a view of the 22 | data with zero overhead. 23 | ] 24 | 25 | __UNDER_CONSTRUCTION__ 26 | 27 | [endsect] 28 | 29 | [section Structured_pair] 30 | 31 | [tip 32 | A structured pair allows you to control the order of the two types. 33 | You can instantiate it so the ['second] member appears in the first 34 | position. 35 | ] 36 | 37 | __UNDER_CONSTRUCTION__ 38 | 39 | 40 | [endsect] 41 | 42 | [section Tagged] 43 | 44 | [tip 45 | Tagged idiom and support metafunctions. 46 | ] 47 | 48 | __UNDER_CONSTRUCTION__ 49 | 50 | 51 | [endsect] 52 | 53 | [section Relation] 54 | 55 | [tip 56 | The bidirectional std::pair cousin. 57 | ] 58 | 59 | __UNDER_CONSTRUCTION__ 60 | 61 | [endsect] 62 | 63 | [section Container_adaptor] 64 | 65 | [tip 66 | Easy way to adapt a container so it behaves different in some aspect. 67 | It is the same concept that is use in iterator_adaptor. 68 | ] 69 | 70 | __UNDER_CONSTRUCTION__ 71 | 72 | [endsect] 73 | 74 | 75 | [endsect] 76 | -------------------------------------------------------------------------------- /example/Jamfile.v2: -------------------------------------------------------------------------------- 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 | # bring in rules for testing 10 | import testing ; 11 | 12 | project : requirements /boost/bimap//boost_bimap ; 13 | 14 | test-suite "examples" 15 | : 16 | [ compile mighty_bimap.cpp ] 17 | [ run simple_bimap.cpp ] 18 | [ run tagged_simple_bimap.cpp ] 19 | [ run step_by_step.cpp ] 20 | [ run population_bimap.cpp 21 | /boost/assign//boost_assign 22 | /boost/foreach//boost_foreach ] 23 | [ run repetitions_counter.cpp 24 | /boost/tokenizer//boost_tokenizer ] 25 | [ compile user_defined_names.cpp ] 26 | [ run standard_map_comparison.cpp ] 27 | [ run at_function_examples.cpp ] 28 | [ run tutorial_modify_and_replace.cpp ] 29 | [ run tutorial_range.cpp ] 30 | [ run unconstrained_collection.cpp ] 31 | [ run tutorial_info_hook.cpp ] 32 | [ run projection.cpp ] 33 | ; 34 | 35 | test-suite "bimap_and_boost" 36 | : 37 | [ run bimap_and_boost/property_map.cpp ] 38 | [ run bimap_and_boost/range.cpp 39 | /boost/range//boost_range ] 40 | [ run bimap_and_boost/foreach.cpp 41 | /boost/foreach//boost_foreach ] 42 | [ run bimap_and_boost/lambda.cpp ] 43 | [ run bimap_and_boost/assign.cpp 44 | /boost/assign//boost_assign ] 45 | [ run bimap_and_boost/xpressive.cpp 46 | /boost/xpressive//boost_xpressive ] 47 | [ run bimap_and_boost/typeof.cpp ] 48 | [ run bimap_and_boost/serialization.cpp 49 | /boost/serialization//boost_serialization ] 50 | ; 51 | 52 | test-suite "mi_to_b_path" 53 | : 54 | [ compile mi_to_b_path/bidirectional_map.cpp 55 | /boost/tokenizer//boost_tokenizer ] 56 | [ run mi_to_b_path/hashed_indices.cpp 57 | /boost/tokenizer//boost_tokenizer ] 58 | [ compile mi_to_b_path/tagged_bidirectional_map.cpp ] 59 | [ compile mi_to_b_path/mi_bidirectional_map.cpp 60 | /boost/tokenizer//boost_tokenizer ] 61 | [ run mi_to_b_path/mi_hashed_indices.cpp 62 | /boost/tokenizer//boost_tokenizer ] 63 | ; 64 | -------------------------------------------------------------------------------- /example/at_function_examples.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | using namespace boost::bimaps; 33 | 34 | void first_bimap() 35 | { 36 | //[ code_at_function_first 37 | 38 | typedef bimap< set_of< std::string >, list_of< int > > bm_type; 39 | bm_type bm; 40 | 41 | try 42 | { 43 | bm.left.at("one") = 1; // throws std::out_of_range 44 | } 45 | catch( std::out_of_range & e ) {} 46 | 47 | assert( bm.empty() ); 48 | 49 | bm.left["one"] = 1; // Ok 50 | 51 | assert( bm.left.at("one") == 1 ); // Ok 52 | //] 53 | } 54 | 55 | void second_bimap() 56 | { 57 | //[ code_at_function_second 58 | 59 | typedef bimap< multiset_of, unordered_set_of > bm_type; 60 | bm_type bm; 61 | 62 | //<- 63 | /* 64 | //-> 65 | bm.right[1] = "one"; // compilation error 66 | //<- 67 | */ 68 | //-> 69 | 70 | bm.right.insert( bm_type::right_value_type(1,"one") ); 71 | 72 | assert( bm.right.at(1) == "one" ); // Ok 73 | 74 | try 75 | { 76 | std::cout << bm.right.at(2); // throws std::out_of_range 77 | } 78 | catch( std::out_of_range & e ) {} 79 | 80 | //<- 81 | /* 82 | //-> 83 | bm.right.at(1) = "1"; // compilation error 84 | //<- 85 | */ 86 | //-> 87 | 88 | //] 89 | } 90 | 91 | int main() 92 | { 93 | first_bimap(); 94 | second_bimap(); 95 | return 0; 96 | } 97 | 98 | -------------------------------------------------------------------------------- /example/bimap_and_boost/assign.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | using namespace boost::bimaps; 33 | using namespace boost; 34 | 35 | 36 | int main() 37 | { 38 | //[ code_bimap_and_boost_assign 39 | 40 | typedef bimap< multiset_of< int >, list_of< std::string > > bm_type; 41 | 42 | // We can use assign::list_of to initialize the container. 43 | 44 | bm_type bm = assign::list_of< bm_type::relation > /*< 45 | Note that `bm_type::relation` has to be used instead of `bm_type::value_type`. 46 | Contrary to `value_type`, `relation` type stores the elements as non const, a 47 | requirement of `assign::list_of` >*/ 48 | ( 1, "one" ) 49 | ( 2, "two" ) 50 | ( 3, "three" ); 51 | 52 | // The left map view is a multiset, again we use insert 53 | 54 | assign::insert( bm.left ) 55 | ( 4, "four" ) 56 | ( 5, "five" ) 57 | ( 6, "six" ); 58 | 59 | // The right map view is a list so we use push_back here 60 | // Note the order of the elements in the list! 61 | 62 | assign::push_back( bm.right ) 63 | ( "seven" , 7 ) 64 | ( "eight" , 8 ); 65 | 66 | assign::push_front( bm.right ) 67 | ( "nine" , 9 ) 68 | ( "ten" , 10 ) 69 | ( "eleven", 11 ); 70 | 71 | // Since it is left_based the main view is a multiset, so we use insert 72 | 73 | assign::insert( bm ) 74 | ( 12, "twelve" ) 75 | ( 13, "thirteen" ); 76 | //] 77 | 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /example/bimap_and_boost/lambda.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | using namespace boost::bimaps; 29 | 30 | int main() 31 | { 32 | //[ code_bimap_and_boost_lambda 33 | 34 | typedef bimap< std::string, int > bm_type; 35 | 36 | bm_type bm; 37 | bm.insert( bm_type::value_type("one",1) ); 38 | bm.insert( bm_type::value_type("two",2) ); 39 | 40 | bm.right.range( 5 < _key, _key < 10 ); 41 | 42 | bm.left.modify_key( bm.left.find("one"), _key = "1" ); 43 | 44 | bm.left.modify_data( bm.left.begin(), _data *= 10 ); 45 | //] 46 | return 0; 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /example/bimap_and_boost/property_map.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | using namespace boost::bimaps; 31 | 32 | //[ code_bimap_and_boost_property_map 33 | 34 | template 35 | void foo(AddressMap & address_map) 36 | { 37 | typedef typename boost::property_traits::value_type value_type; 38 | typedef typename boost::property_traits::key_type key_type; 39 | 40 | value_type address; 41 | key_type fred = "Fred"; 42 | std::cout << boost::get(address_map, fred); 43 | } 44 | 45 | int main() 46 | { 47 | typedef bimap > Name2Address; 48 | typedef Name2Address::value_type location; 49 | 50 | Name2Address name2address; 51 | name2address.insert( location("Fred", "710 West 13th Street") ); 52 | name2address.insert( location( "Joe", "710 West 13th Street") ); 53 | 54 | foo( name2address.left ); 55 | 56 | return 0; 57 | } 58 | //] 59 | 60 | -------------------------------------------------------------------------------- /example/bimap_and_boost/serialization.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | using namespace boost::bimaps; 33 | 34 | int main() 35 | { 36 | //[ code_bimap_and_boost_serialization 37 | 38 | typedef bimap< std::string, int > bm_type; 39 | 40 | // Create a bimap and serialize it to a file 41 | { 42 | bm_type bm; 43 | bm.insert( bm_type::value_type("one",1) ); 44 | bm.insert( bm_type::value_type("two",2) ); 45 | 46 | std::ofstream ofs("data"); 47 | boost::archive::text_oarchive oa(ofs); 48 | 49 | oa << const_cast(bm); /*< 50 | We must do a const cast because Boost.Serialization archives 51 | only save const objects. Read Boost.Serializartion docs for the 52 | rationale behind this decision >*/ 53 | 54 | /*<< We can only serialize iterators if the bimap was serialized first. 55 | Note that the const cast is not required here because we create 56 | our iterators as const. >>*/ 57 | const bm_type::left_iterator left_iter = bm.left.find("two"); 58 | oa << left_iter; 59 | 60 | const bm_type::right_iterator right_iter = bm.right.find(1); 61 | oa << right_iter; 62 | } 63 | 64 | // Load the bimap back 65 | { 66 | bm_type bm; 67 | 68 | std::ifstream ifs("data", std::ios::binary); 69 | boost::archive::text_iarchive ia(ifs); 70 | 71 | ia >> bm; 72 | 73 | assert( bm.size() == 2 ); 74 | 75 | bm_type::left_iterator left_iter; 76 | ia >> left_iter; 77 | 78 | assert( left_iter->first == "two" ); 79 | 80 | bm_type::right_iterator right_iter; 81 | ia >> right_iter; 82 | 83 | assert( right_iter->first == 1 ); 84 | } 85 | //] 86 | 87 | return 0; 88 | } 89 | 90 | -------------------------------------------------------------------------------- /example/bimap_and_boost/typeof.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | using namespace boost::bimaps; 30 | 31 | struct name {}; 32 | struct number {}; 33 | 34 | void using_auto() 35 | { 36 | //[ code_bimap_and_boost_typeof_first 37 | 38 | typedef bimap< tagged, tagged > bm_type; 39 | bm_type bm; 40 | bm.insert( bm_type::value_type("one" ,1) ); 41 | bm.insert( bm_type::value_type("two" ,2) ); 42 | //] 43 | 44 | //[ code_bimap_and_boost_typeof_using_auto 45 | 46 | for( BOOST_AUTO(iter, bm.by().begin()); iter!=bm.by().end(); ++iter) 47 | { 48 | std::cout << iter->first << " --> " << iter->second << std::endl; 49 | } 50 | 51 | BOOST_AUTO( iter, bm.by().find(2) ); 52 | std::cout << "2: " << iter->get(); 53 | //] 54 | } 55 | 56 | void not_using_auto() 57 | { 58 | typedef bimap< tagged, tagged > bm_type; 59 | bm_type bm; 60 | bm.insert( bm_type::value_type("one" ,1) ); 61 | bm.insert( bm_type::value_type("two" ,2) ); 62 | 63 | //[ code_bimap_and_boost_typeof_not_using_auto 64 | 65 | for( bm_type::map_by::iterator iter = bm.by().begin(); 66 | iter!=bm.by().end(); ++iter) 67 | { 68 | std::cout << iter->first << " --> " << iter->second << std::endl; 69 | } 70 | 71 | bm_type::map_by::iterator iter = bm.by().find(2); 72 | std::cout << "2: " << iter->get(); 73 | //] 74 | } 75 | 76 | int main() 77 | { 78 | using_auto(); 79 | not_using_auto(); 80 | 81 | return 0; 82 | } 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /example/bimap_and_boost/xpressive.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | using namespace boost::bimaps; 31 | using namespace boost::xpressive; 32 | namespace xp = boost::xpressive; 33 | 34 | int main() 35 | { 36 | //[ code_bimap_and_boost_xpressive 37 | 38 | typedef bimap< std::string, int > bm_type; 39 | bm_type bm; 40 | 41 | std::string rel_str("one <--> 1 two <--> 2 three <--> 3"); 42 | 43 | sregex rel = ( (s1= +_w) >> " <--> " >> (s2= +_d) ) 44 | [ 45 | xp::ref(bm)->*insert( xp::construct(s1, as(s2)) ) 46 | ]; 47 | 48 | sregex relations = rel >> *(+_s >> rel); 49 | 50 | regex_match(rel_str, relations); 51 | 52 | assert( bm.size() == 3 ); 53 | //] 54 | 55 | return 0; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /example/mi_to_b_path/bidirectional_map.cpp: -------------------------------------------------------------------------------- 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 | 10 | // Boost.Bimap Example 11 | //----------------------------------------------------------------------------- 12 | // This example shows how to construct a bidirectional map with 13 | // multi_index_container. 14 | // By a bidirectional map we mean a container of elements of 15 | // std::pair such that no two elements exists with 16 | // the same first or second value (std::map only guarantees uniqueness of the 17 | // first member). 18 | // Fast lookup is provided for both keys. The program features a tiny 19 | // Spanish-English dictionary with online query of words in both languages. 20 | 21 | #include 22 | 23 | //[ code_mi_to_b_path_bidirectional_map 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | using namespace boost::bimaps; 30 | 31 | // A dictionary is a bidirectional map from strings to strings 32 | 33 | typedef bimap dictionary; 34 | typedef dictionary::value_type translation; 35 | 36 | int main() 37 | { 38 | dictionary d; 39 | 40 | // Fill up our microdictionary. 41 | // first members Spanish, second members English. 42 | 43 | d.insert( translation("hola" ,"hello" )); 44 | d.insert( translation("adios","goodbye")); 45 | d.insert( translation("rosa" ,"rose" )); 46 | d.insert( translation("mesa" ,"table" )); 47 | 48 | std::cout << "enter a word" << std::endl; 49 | std::string word; 50 | std::getline(std::cin,word); 51 | 52 | // search the queried word on the from index (Spanish) 53 | 54 | dictionary::left_const_iterator it = d.left.find(word); 55 | 56 | if( it != d.left.end() ) 57 | { 58 | // the second part of the element is the equivalent in English 59 | 60 | std::cout << word << " is said " 61 | << it->second /*< `it` is an iterator of the left view, so 62 | `it->second` refers to the right element of 63 | the relation, the word in english >*/ 64 | << " in English" << std::endl; 65 | } 66 | else 67 | { 68 | // word not found in Spanish, try our luck in English 69 | 70 | dictionary::right_const_iterator it2 = d.right.find(word); 71 | if( it2 != d.right.end() ) 72 | { 73 | std::cout << word << " is said " 74 | << it2->second /*< `it2` is an iterator of the right view, so 75 | `it2->second` refers to the left element of 76 | the relation, the word in spanish >*/ 77 | << " in Spanish" << std::endl; 78 | } 79 | else 80 | { 81 | std::cout << "No such word in the dictionary" << std::endl; 82 | } 83 | } 84 | 85 | return 0; 86 | } 87 | //] 88 | -------------------------------------------------------------------------------- /example/mi_to_b_path/hashed_indices.cpp: -------------------------------------------------------------------------------- 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 | 10 | // Boost.Bimap Example 11 | //----------------------------------------------------------------------------- 12 | // Hashed indices can be used as an alternative to ordered indices when fast 13 | // lookup is needed and sorting information is of no interest. The example 14 | // features a word counter where duplicate entries are checked by means of a 15 | // hashed index. 16 | 17 | #include 18 | 19 | //[ code_mi_to_b_path_hashed_indices 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | using namespace boost::bimaps; 32 | 33 | struct word {}; 34 | struct occurrences {}; 35 | 36 | typedef bimap 37 | < 38 | 39 | multiset_of< tagged, std::greater >, 40 | unordered_set_of< tagged< std::string, word> > 41 | 42 | > word_counter; 43 | 44 | typedef boost::tokenizer > text_tokenizer; 45 | 46 | int main() 47 | { 48 | 49 | std::string text= 50 | "Relations between data in the STL are represented with maps." 51 | "A map is a directed relation, by using it you are representing " 52 | "a mapping. In this directed relation, the first type is related to " 53 | "the second type but it is not true that the inverse relationship " 54 | "holds. This is useful in a lot of situations, but there are some " 55 | "relationships that are bidirectional by nature."; 56 | 57 | // feed the text into the container 58 | 59 | word_counter wc; 60 | text_tokenizer tok(text,boost::char_separator(" \t\n.,;:!?'\"-")); 61 | unsigned int total_occurrences = 0; 62 | 63 | for( text_tokenizer::const_iterator it = tok.begin(), it_end = tok.end(); 64 | it != it_end ; ++it ) 65 | { 66 | ++total_occurrences; 67 | 68 | word_counter::map_by::iterator wit = 69 | wc.by().insert( 70 | word_counter::map_by::value_type(0,*it) 71 | ).first; 72 | 73 | wc.by().modify_key( wit, ++_key); 74 | } 75 | 76 | // list words by frequency of appearance 77 | 78 | std::cout << std::fixed << std::setprecision(2); 79 | 80 | for( word_counter::map_by::const_iterator 81 | wit = wc.by().begin(), 82 | wit_end = wc.by().end(); 83 | 84 | wit != wit_end; ++wit ) 85 | { 86 | std::cout << std::setw(15) << wit->get() << ": " 87 | << std::setw(5) 88 | << 100.0 * wit->get() / total_occurrences << "%" 89 | << std::endl; 90 | } 91 | 92 | return 0; 93 | } 94 | //] 95 | -------------------------------------------------------------------------------- /example/mi_to_b_path/mi_bidirectional_map.cpp: -------------------------------------------------------------------------------- 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 | /****************************************************************************** 10 | Boost.MultiIndex 11 | ******************************************************************************/ 12 | 13 | #include 14 | 15 | //[ code_mi_to_b_path_mi_bidirectional_map 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | using namespace boost; 25 | using namespace boost::multi_index; 26 | 27 | // tags for accessing both sides of a bidirectional map 28 | 29 | struct from {}; 30 | struct to {}; 31 | 32 | // The class template bidirectional_map wraps the specification 33 | // of a bidirectional map based on multi_index_container. 34 | 35 | template 36 | struct bidirectional_map 37 | { 38 | typedef std::pair value_type; 39 | 40 | typedef multi_index_container< 41 | value_type, 42 | indexed_by 43 | < 44 | ordered_unique 45 | < 46 | tag, member 47 | >, 48 | ordered_unique 49 | < 50 | tag, member 51 | > 52 | > 53 | 54 | > type; 55 | 56 | }; 57 | 58 | // A dictionary is a bidirectional map from strings to strings 59 | 60 | typedef bidirectional_map::type dictionary; 61 | 62 | int main() 63 | { 64 | dictionary d; 65 | 66 | // Fill up our microdictionary. 67 | // first members Spanish, second members English. 68 | 69 | d.insert(dictionary::value_type("hola","hello")); 70 | d.insert(dictionary::value_type("adios","goodbye")); 71 | d.insert(dictionary::value_type("rosa","rose")); 72 | d.insert(dictionary::value_type("mesa","table")); 73 | 74 | std::cout << "enter a word" << std::endl; 75 | std::string word; 76 | std::getline(std::cin,word); 77 | 78 | // search the queried word on the from index (Spanish) 79 | 80 | dictionary::iterator it = d.get().find(word); 81 | 82 | if( it != d.end() ) 83 | { 84 | // the second part of the element is the equivalent in English 85 | 86 | std::cout << word << " is said " 87 | << it->second << " in English" << std::endl; 88 | } 89 | else 90 | { 91 | // word not found in Spanish, try our luck in English 92 | 93 | dictionary::index_iterator::type it2 = d.get().find(word); 94 | if( it2 != d.get().end() ) 95 | { 96 | std::cout << word << " is said " 97 | << it2->first << " in Spanish" << std::endl; 98 | } 99 | else 100 | { 101 | std::cout << "No such word in the dictionary" << std::endl; 102 | } 103 | } 104 | 105 | return 0; 106 | } 107 | //] 108 | -------------------------------------------------------------------------------- /example/mi_to_b_path/mi_hashed_indices.cpp: -------------------------------------------------------------------------------- 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 | 10 | /***************************************************************************** 11 | Boost.MultiIndex 12 | *****************************************************************************/ 13 | 14 | #include 15 | 16 | //[ code_mi_to_b_path_mi_hashed_indices 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | using namespace boost::multi_index; 30 | namespace bl = boost::lambda; 31 | 32 | // word_counter keeps the occurrences of words inserted. A hashed 33 | // index allows for fast checking of preexisting entries. 34 | 35 | struct word_counter_entry 36 | { 37 | std::string word; 38 | unsigned int occurrences; 39 | 40 | word_counter_entry( std::string word_ ) : word(word_), occurrences(0) {} 41 | }; 42 | 43 | typedef multi_index_container 44 | < 45 | word_counter_entry, 46 | indexed_by 47 | < 48 | ordered_non_unique 49 | < 50 | BOOST_MULTI_INDEX_MEMBER( 51 | word_counter_entry,unsigned int,occurrences), 52 | std::greater 53 | >, 54 | hashed_unique 55 | < 56 | BOOST_MULTI_INDEX_MEMBER(word_counter_entry,std::string,word) 57 | > 58 | > 59 | 60 | > word_counter; 61 | 62 | typedef boost::tokenizer > text_tokenizer; 63 | 64 | int main() 65 | { 66 | std::string text= 67 | "En un lugar de la Mancha, de cuyo nombre no quiero acordarme... " 68 | "...snip..." 69 | "...no se salga un punto de la verdad."; 70 | 71 | // feed the text into the container 72 | 73 | word_counter wc; 74 | text_tokenizer tok(text,boost::char_separator(" \t\n.,;:!?'\"-")); 75 | unsigned int total_occurrences = 0; 76 | 77 | for( text_tokenizer::iterator it = tok.begin(), it_end = tok.end(); 78 | it != it_end ; ++it ) 79 | { 80 | ++total_occurrences; 81 | word_counter::iterator wit = wc.insert(*it).first; 82 | wc.modify_key( wit, ++ bl::_1 ); 83 | } 84 | 85 | // list words by frequency of appearance 86 | 87 | std::cout << std::fixed << std::setprecision(2); 88 | 89 | for( word_counter::iterator wit = wc.begin(), wit_end=wc.end(); 90 | wit != wit_end; ++wit ) 91 | { 92 | std::cout << std::setw(11) << wit->word << ": " 93 | << std::setw(5) 94 | << 100.0 * wit->occurrences / total_occurrences << "%" 95 | << std::endl; 96 | } 97 | 98 | return 0; 99 | } 100 | //] 101 | -------------------------------------------------------------------------------- /example/mi_to_b_path/tagged_bidirectional_map.cpp: -------------------------------------------------------------------------------- 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 | 10 | // Boost.Bimap Example 11 | //----------------------------------------------------------------------------- 12 | // This example shows how to construct a bidirectional map with 13 | // multi_index_container. 14 | // By a bidirectional map we mean a container of elements of 15 | // std::pair such that no two elements exists with 16 | // the same first or second value (std::map only guarantees uniqueness of the 17 | // first member). 18 | // Fast lookup is provided for both keys. The program features a tiny 19 | // Spanish-English dictionary with online query of words in both languages. 20 | 21 | //[ code_mi_to_b_path_tagged_bidirectional_map 22 | 23 | #include 24 | 25 | #include 26 | 27 | using namespace boost::bimaps; 28 | 29 | // tags 30 | 31 | struct spanish {}; 32 | struct english {}; 33 | 34 | // A dictionary is a bidirectional map from strings to strings 35 | 36 | typedef bimap 37 | < 38 | tagged< std::string,spanish >, tagged< std::string,english > 39 | 40 | > dictionary; 41 | 42 | typedef dictionary::value_type translation; 43 | 44 | int main() 45 | { 46 | dictionary d; 47 | 48 | // Fill up our microdictionary. 49 | // first members Spanish, second members English. 50 | 51 | d.insert( translation("hola" ,"hello" )); 52 | d.insert( translation("adios","goodbye")); 53 | d.insert( translation("rosa" ,"rose" )); 54 | d.insert( translation("mesa" ,"table" )); 55 | 56 | std::cout << "enter a word" << std::endl; 57 | std::string word; 58 | std::getline(std::cin,word); 59 | 60 | // search the queried word on the from index (Spanish) */ 61 | 62 | dictionary::map_by::const_iterator it = 63 | d.by().find(word); 64 | 65 | if( it != d.by().end() ) 66 | { 67 | std::cout << word << " is said " 68 | << it->get() << " in English" << std::endl; 69 | } 70 | else 71 | { 72 | // word not found in Spanish, try our luck in English 73 | 74 | dictionary::map_by::const_iterator it2 = 75 | d.by().find(word); 76 | 77 | if( it2 != d.by().end() ) 78 | { 79 | std::cout << word << " is said " 80 | << it2->get() << " in Spanish" << std::endl; 81 | } 82 | else 83 | { 84 | std::cout << "No such word in the dictionary" << std::endl; 85 | } 86 | } 87 | 88 | return 0; 89 | } 90 | //] 91 | -------------------------------------------------------------------------------- /example/projection.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | using namespace boost::bimaps; 29 | 30 | void years_example() 31 | { 32 | //[ code_projection_years 33 | 34 | typedef bimap > > bm_type; 35 | 36 | bm_type bm; 37 | bm.insert( bm_type::value_type("John" ,34) ); 38 | bm.insert( bm_type::value_type("Peter",24) ); 39 | bm.insert( bm_type::value_type("Mary" ,12) ); 40 | 41 | // Find the name of the next younger person after Peter 42 | 43 | bm_type::left_const_iterator name_iter = bm.left.find("Peter"); 44 | 45 | bm_type::right_const_iterator years_iter = bm.project_right(name_iter); 46 | 47 | ++years_iter; 48 | 49 | std::cout << "The next younger person after Peter is " << years_iter->second; 50 | //] 51 | } 52 | 53 | int main() 54 | { 55 | years_example(); 56 | 57 | return 0; 58 | } 59 | 60 | 61 | -------------------------------------------------------------------------------- /example/repetitions_counter.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | using namespace boost::bimaps; 31 | 32 | struct counter { 33 | counter() : c(0) {} 34 | counter& operator++() { ++c; return *this; } 35 | unsigned int operator++(int) { return c++; } 36 | operator const unsigned int() const { return c; } 37 | private: 38 | unsigned int c; 39 | }; 40 | 41 | int main() 42 | { 43 | //[ code_repetitions_counter 44 | 45 | typedef bimap 46 | < 47 | unordered_set_of< std::string >, 48 | list_of< counter > /*< `counter` is an integer that is initialized 49 | in zero in the constructor >*/ 50 | 51 | > word_counter; 52 | 53 | typedef boost::tokenizer > text_tokenizer; 54 | 55 | std::string text= 56 | "Relations between data in the STL are represented with maps." 57 | "A map is a directed relation, by using it you are representing " 58 | "a mapping. In this directed relation, the first type is related to " 59 | "the second type but it is not true that the inverse relationship " 60 | "holds. This is useful in a lot of situations, but there are some " 61 | "relationships that are bidirectional by nature."; 62 | 63 | // feed the text into the container 64 | word_counter wc; 65 | text_tokenizer tok(text,boost::char_separator(" \t\n.,;:!?'\"-")); 66 | 67 | for( text_tokenizer::const_iterator it = tok.begin(), it_end = tok.end(); 68 | it != it_end ; ++it ) 69 | { 70 | /*<< Because the right collection type is `list_of`, the right data 71 | is not used a key and can be modified in the same way as with 72 | standard maps. >>*/ 73 | ++ wc.left[*it]; 74 | } 75 | 76 | // list words with counters by order of appearance 77 | /*<< When we insert the elements using the left map view, the element 78 | is inserted at the end of the list. >>*/ 79 | for( word_counter::right_const_iterator 80 | wit = wc.right.begin(), wit_end = wc.right.end(); 81 | 82 | wit != wit_end; ++wit ) 83 | { 84 | std::cout << wit->second << ": " << wit->first; 85 | } 86 | //] 87 | 88 | return 0; 89 | } 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/simple_bimap.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | //[ code_simple_bimap 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | template< class MapType > 31 | void print_map(const MapType & map, 32 | const std::string & separator, 33 | std::ostream & os ) 34 | { 35 | typedef typename MapType::const_iterator const_iterator; 36 | 37 | for( const_iterator i = map.begin(), iend = map.end(); i != iend; ++i ) 38 | { 39 | os << i->first << separator << i->second << std::endl; 40 | } 41 | } 42 | 43 | int main() 44 | { 45 | // Soccer World cup 46 | 47 | typedef boost::bimap< std::string, int > results_bimap; 48 | typedef results_bimap::value_type position; 49 | 50 | results_bimap results; 51 | results.insert( position("Argentina" ,1) ); 52 | results.insert( position("Spain" ,2) ); 53 | results.insert( position("Germany" ,3) ); 54 | results.insert( position("France" ,4) ); 55 | 56 | std::cout << "The number of countries is " << results.size() 57 | << std::endl; 58 | 59 | std::cout << "The winner is " << results.right.at(1) 60 | << std::endl 61 | << std::endl; 62 | 63 | std::cout << "Countries names ordered by their final position:" 64 | << std::endl; 65 | 66 | // results.right works like a std::map< int, std::string > 67 | 68 | print_map( results.right, ") ", std::cout ); 69 | 70 | std::cout << std::endl 71 | << "Countries names ordered alphabetically along with" 72 | "their final position:" 73 | << std::endl; 74 | 75 | // results.left works like a std::map< std::string, int > 76 | 77 | print_map( results.left, " ends in position ", std::cout ); 78 | 79 | return 0; 80 | } 81 | //] 82 | 83 | -------------------------------------------------------------------------------- /example/standard_map_comparison.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | using namespace boost::bimaps; 30 | 31 | //[ code_standard_map_comparison 32 | 33 | template< class Map, class CompatibleKey, class CompatibleData > 34 | void use_it( Map & m, 35 | const CompatibleKey & key, 36 | const CompatibleData & data ) 37 | { 38 | typedef typename Map::value_type value_type; 39 | typedef typename Map::const_iterator const_iterator; 40 | 41 | m.insert( value_type(key,data) ); 42 | const_iterator iter = m.find(key); 43 | if( iter != m.end() ) 44 | { 45 | assert( iter->first == key ); 46 | assert( iter->second == data ); 47 | 48 | std::cout << iter->first << " --> " << iter->second; 49 | } 50 | m.erase(key); 51 | } 52 | 53 | int main() 54 | { 55 | typedef bimap< set_of, set_of > bimap_type; 56 | bimap_type bm; 57 | 58 | // Standard map 59 | { 60 | typedef std::map< std::string, int > map_type; 61 | map_type m; 62 | 63 | use_it( m, "one", 1 ); 64 | } 65 | 66 | // Left map view 67 | { 68 | typedef bimap_type::left_map map_type; 69 | map_type & m = bm.left; 70 | 71 | use_it( m, "one", 1 ); 72 | } 73 | 74 | // Reverse standard map 75 | { 76 | typedef std::map< int, std::string > reverse_map_type; 77 | reverse_map_type rm; 78 | 79 | use_it( rm, 1, "one" ); 80 | } 81 | 82 | // Right map view 83 | { 84 | typedef bimap_type::right_map reverse_map_type; 85 | reverse_map_type & rm = bm.right; 86 | 87 | use_it( rm, 1, "one" ); 88 | } 89 | 90 | return 0; 91 | } 92 | //] 93 | 94 | -------------------------------------------------------------------------------- /example/tagged_simple_bimap.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | //[ code_tagged_simple_bimap 24 | 25 | #include 26 | 27 | #include 28 | 29 | struct country {}; 30 | struct place {}; 31 | 32 | int main() 33 | { 34 | using namespace boost::bimaps; 35 | 36 | // Soccer World cup. 37 | 38 | typedef bimap 39 | < 40 | tagged< std::string, country >, 41 | tagged< int , place > 42 | 43 | > results_bimap; 44 | 45 | typedef results_bimap::value_type position; 46 | 47 | results_bimap results; 48 | results.insert( position("Argentina" ,1) ); 49 | results.insert( position("Spain" ,2) ); 50 | results.insert( position("Germany" ,3) ); 51 | results.insert( position("France" ,4) ); 52 | 53 | std::cout << "Countries names ordered by their final position:" 54 | << std::endl; 55 | 56 | /*<< `results.by()` is equivalent to `results.right` >>*/ 57 | for( results_bimap::map_by::const_iterator 58 | i = results.by().begin(), 59 | iend = results.by().end() ; 60 | i != iend; ++i ) 61 | { 62 | /*<< `get` works for each view of the bimap >>*/ 63 | std::cout << i->get() << ") " 64 | << i->get() << std::endl; 65 | } 66 | 67 | std::cout << std::endl 68 | << "Countries names ordered alfabetically along with" 69 | "their final position:" 70 | << std::endl; 71 | 72 | /*<< `results.by()` is equivalent to `results.left` >>*/ 73 | for( results_bimap::map_by::const_iterator 74 | i = results.by().begin(), 75 | iend = results.by().end() ; 76 | i != iend; ++i ) 77 | { 78 | std::cout << i->get() << " ends " 79 | << i->get() << "º" 80 | << std::endl; 81 | } 82 | 83 | return 0; 84 | } 85 | //] 86 | 87 | -------------------------------------------------------------------------------- /example/tutorial_range.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | using namespace boost::bimaps; 30 | 31 | void using_upper_and_lower_bound() 32 | { 33 | //[ code_tutorial_range_standard_way 34 | 35 | typedef bimap bm_type; 36 | bm_type bm; 37 | 38 | // ... 39 | 40 | bm_type::left_iterator iter_first = bm.left.lower_bound(20); 41 | bm_type::left_iterator iter_second = bm.left.upper_bound(50); 42 | 43 | // range [iter_first,iter_second) contains the elements in [20,50] 44 | //] 45 | 46 | // Subtle changes 47 | { 48 | //[ code_tutorial_range_standard_way_subtle_changes 49 | 50 | bm_type::left_iterator iter_first = bm.left.upper_bound(20); 51 | bm_type::left_iterator iter_second = bm.left.lower_bound(50); 52 | 53 | // range [iter_first,iter_second) contains the elements in (20,50) 54 | //] 55 | } 56 | } 57 | 58 | void using_range() 59 | { 60 | //[ code_tutorial_range 61 | 62 | typedef bimap bm_type; 63 | bm_type bm; 64 | 65 | // ... 66 | 67 | /*<< `range_type` is a handy typedef equal to `std::pair`. 68 | `const_range_type` is provided too, and it is equal to 69 | `std::pair` >>*/ 70 | bm_type::left_range_type r; 71 | 72 | /*<< _key is a Boost.Lambda placeholder. To use it you have to include 73 | `` >>*/ 74 | r = bm.left.range( 20 <= _key, _key <= 50 ); // [20,50] 75 | 76 | r = bm.left.range( 20 < _key, _key < 50 ); // (20,50) 77 | 78 | r = bm.left.range( 20 <= _key, _key < 50 ); // [20,50) 79 | //] 80 | 81 | //[ code_tutorial_range_unbounded 82 | 83 | r = bm.left.range( 20 <= _key, unbounded ); // [20,inf) 84 | 85 | r = bm.left.range( unbounded , _key < 50 ); // (-inf,50) 86 | 87 | /*<< This is equivalent to std::make_pair(s.begin(),s.end()) >>*/ 88 | r = bm.left.range( unbounded , unbounded ); // (-inf,inf) 89 | //] 90 | } 91 | 92 | int main() 93 | { 94 | using_upper_and_lower_bound(); 95 | using_range(); 96 | 97 | return 0; 98 | } 99 | 100 | 101 | -------------------------------------------------------------------------------- /example/unconstrained_collection.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | // Boost.Bimap Example 19 | //----------------------------------------------------------------------------- 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | using namespace boost::bimaps; 32 | 33 | int main() 34 | { 35 | // Boost.Bimap 36 | { 37 | //[ code_unconstrained_collection_bimap 38 | 39 | typedef bimap< std::string, unconstrained_set_of > bm_type; 40 | typedef bm_type::left_map map_type; 41 | 42 | bm_type bm; 43 | map_type & m = bm.left; 44 | //] 45 | 46 | //[ code_unconstrained_collection_common 47 | 48 | m["one"] = 1; 49 | 50 | assert( m.find("one") != m.end() ); 51 | 52 | for( map_type::iterator i = m.begin(), iend = m.end(); i != iend; ++i ) 53 | { 54 | /*<< The right collection of the bimap is mutable so its elements 55 | can be modified using iterators. >>*/ 56 | ++(i->second); 57 | } 58 | 59 | m.erase("one"); 60 | //] 61 | 62 | m["one"] = 1; 63 | m["two"] = 2; 64 | 65 | //[ code_unconstrained_collection_only_for_bimap 66 | typedef map_type::const_iterator const_iterator; 67 | typedef std::pair const_range; 68 | 69 | /*<< This range is a model of BidirectionalRange, read the docs of 70 | Boost.Range for more information. >>*/ 71 | const_range r = m.range( "one" <= _key, _key <= "two" ); 72 | for( const_iterator i = r.first; i != r.second; ++i ) 73 | { 74 | std::cout << i->first << "-->" << i->second << std::endl; 75 | } 76 | 77 | m.modify_key( m.begin(), _key = "1" ); 78 | //] 79 | } 80 | 81 | // Standard map 82 | { 83 | //[ code_unconstrained_collection_map 84 | 85 | typedef std::map< std::string, int > map_type; 86 | 87 | map_type m; 88 | //] 89 | } 90 | 91 | return 0; 92 | } 93 | 94 | 95 | -------------------------------------------------------------------------------- /include/boost/bimap.hpp: -------------------------------------------------------------------------------- 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 | // See www.boost.org/libs/bimap for documentation. 10 | 11 | // Convenience header 12 | 13 | #include 14 | 15 | namespace boost 16 | { 17 | using ::boost::bimaps::bimap; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /include/boost/bimap/container_adaptor/detail/functor_bag.hpp: -------------------------------------------------------------------------------- 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 container_adaptor/detail/functor_bag.hpp 10 | /// \brief Defines a EBO optimizacion helper for functors. 11 | 12 | #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_FUNCTOR_BAG_HPP 13 | #define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_FUNCTOR_BAG_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #if defined(BOOST_MSVC) 22 | // This bogus warning will appear when add_const is applied to a 23 | // const volatile reference because we can't detect const volatile 24 | // references with MSVC6. 25 | # pragma warning(push) 26 | # pragma warning(disable:4181) 27 | // warning C4181: qualifier applied to reference type ignored 28 | #endif 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | 38 | namespace boost { 39 | namespace bimaps { 40 | namespace container_adaptor { 41 | namespace detail { 42 | 43 | /// \brief EBO optimizacion helper for functors 44 | /** 45 | 46 | This class is a generalization of a helper class explained in an article by 47 | Nathan C. Myers.\n 48 | See it at \link http://www.cantrip.org/emptyopt.html 49 | **/ 50 | 51 | template < class Data, class FunctorList > 52 | struct data_with_functor_bag : 53 | 54 | public mpl::inherit_linearly< 55 | 56 | FunctorList, 57 | mpl::if_< is_base_of< mpl::_2, mpl::_1 >, 58 | // { 59 | mpl::_1, 60 | // } 61 | // else 62 | // { 63 | mpl::inherit< mpl::_1, mpl::_2 > 64 | // } 65 | > 66 | 67 | >::type 68 | { 69 | Data data; 70 | 71 | data_with_functor_bag() {} 72 | 73 | data_with_functor_bag(BOOST_DEDUCED_TYPENAME add_reference::type d) 74 | : data(d) {} 75 | 76 | template< class Functor > 77 | Functor& functor() 78 | { 79 | return *(static_cast(this)); 80 | } 81 | 82 | template< class Functor > 83 | const Functor& functor() const 84 | { 85 | return *(static_cast(this)); 86 | } 87 | }; 88 | 89 | } // namespace detail 90 | } // namespace container_adaptor 91 | } // namespace bimaps 92 | } // namespace boost 93 | 94 | #if defined(BOOST_MSVC) 95 | # pragma warning(pop) 96 | #endif 97 | 98 | #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_FUNCTOR_BAG_HPP 99 | 100 | 101 | -------------------------------------------------------------------------------- /include/boost/bimap/container_adaptor/detail/key_extractor.hpp: -------------------------------------------------------------------------------- 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 container_adaptor/detail/key_extractor.hpp 10 | /// \brief Key extractor for a pair. 11 | 12 | #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_KEY_EXTRACTOR_HPP 13 | #define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_KEY_EXTRACTOR_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | namespace boost { 22 | namespace bimaps { 23 | namespace container_adaptor { 24 | namespace detail { 25 | 26 | /// \brief Key Extractor 27 | 28 | template < class T > 29 | struct key_from_pair_extractor 30 | { 31 | typedef T argument_type; 32 | typedef BOOST_DEDUCED_TYPENAME T::first_type result_type; 33 | 34 | result_type operator()( const T & p ) { return p.first; } 35 | }; 36 | 37 | } // namespace detail 38 | } // namespace container_adaptor 39 | } // namespace bimaps 40 | } // namespace boost 41 | 42 | 43 | #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_KEY_EXTRACTOR_HPP 44 | 45 | 46 | -------------------------------------------------------------------------------- /include/boost/bimap/container_adaptor/set_adaptor.hpp: -------------------------------------------------------------------------------- 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 container_adaptor/set_adaptor.hpp 10 | /// \brief Container adaptor to easily build a std::set signature compatible container. 11 | 12 | #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_SET_ADAPTOR_HPP 13 | #define BOOST_BIMAP_CONTAINER_ADAPTOR_SET_ADAPTOR_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace boost { 26 | namespace bimaps { 27 | namespace container_adaptor { 28 | 29 | /// \brief Container adaptor to easily build a std::set signature compatible container. 30 | 31 | template 32 | < 33 | class Base, 34 | 35 | class Iterator, 36 | class ConstIterator, 37 | class ReverseIterator, 38 | class ConstReverseIterator, 39 | 40 | class IteratorToBaseConverter = ::boost::mpl::na, 41 | class IteratorFromBaseConverter = ::boost::mpl::na, 42 | class ReverseIteratorFromBaseConverter = ::boost::mpl::na, 43 | class ValueToBaseConverter = ::boost::mpl::na, 44 | class ValueFromBaseConverter = ::boost::mpl::na, 45 | class KeyToBaseConverter = ::boost::mpl::na, 46 | 47 | class FunctorsFromDerivedClasses = mpl::vector<> 48 | > 49 | class set_adaptor : 50 | 51 | public ::boost::bimaps::container_adaptor:: 52 | ordered_associative_container_adaptor 53 | < 54 | Base, 55 | Iterator, ConstIterator, ReverseIterator, ConstReverseIterator, 56 | BOOST_DEDUCED_TYPENAME Iterator::value_type, 57 | IteratorToBaseConverter, IteratorFromBaseConverter, 58 | ReverseIteratorFromBaseConverter, 59 | ValueToBaseConverter, ValueFromBaseConverter, 60 | KeyToBaseConverter, 61 | FunctorsFromDerivedClasses 62 | > 63 | { 64 | 65 | typedef ::boost::bimaps::container_adaptor:: 66 | ordered_associative_container_adaptor 67 | < 68 | Base, 69 | Iterator, ConstIterator, ReverseIterator, ConstReverseIterator, 70 | BOOST_DEDUCED_TYPENAME Iterator::value_type, 71 | IteratorToBaseConverter, IteratorFromBaseConverter, 72 | ReverseIteratorFromBaseConverter, 73 | ValueToBaseConverter, ValueFromBaseConverter, 74 | KeyToBaseConverter, 75 | FunctorsFromDerivedClasses 76 | 77 | > base_; 78 | 79 | // Access ----------------------------------------------------------------- 80 | 81 | public: 82 | 83 | explicit set_adaptor(Base & c) : 84 | base_(c) {} 85 | 86 | protected: 87 | 88 | typedef set_adaptor set_adaptor_; 89 | 90 | }; 91 | 92 | 93 | } // namespace container_adaptor 94 | } // namespace bimaps 95 | } // namespace boost 96 | 97 | 98 | #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_SET_ADAPTOR_HPP 99 | 100 | 101 | -------------------------------------------------------------------------------- /include/boost/bimap/container_adaptor/support/iterator_facade_converters.hpp: -------------------------------------------------------------------------------- 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 container_adaptor/support/iterator_facade_converters.hpp 10 | /// \brief Converter for Boost.Iterators based iterators. 11 | 12 | #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_ITERATOR_FACADE_CONVERTERS_HPP 13 | #define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_ITERATOR_FACADE_CONVERTERS_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | namespace boost { 22 | namespace bimaps { 23 | namespace container_adaptor { 24 | 25 | /// \brief Utilities to help in the construction of a container adaptor 26 | 27 | namespace support { 28 | 29 | /// \brief Converter for Boost.Iterators based iterators. 30 | /** 31 | Container adaptor is designed to play well with Boost.Iterators. This 32 | converter can be used if this library is used to adapt the iterators. 33 | **/ 34 | template 35 | < 36 | class Iterator, 37 | class ConstIterator 38 | > 39 | struct iterator_facade_to_base 40 | { 41 | BOOST_DEDUCED_TYPENAME Iterator::base_type operator()(Iterator iter) const 42 | { 43 | return iter.base(); 44 | } 45 | 46 | BOOST_DEDUCED_TYPENAME ConstIterator::base_type operator()(ConstIterator iter) const 47 | { 48 | return iter.base(); 49 | } 50 | }; 51 | 52 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 53 | 54 | template 55 | < 56 | class Iterator 57 | > 58 | struct iterator_facade_to_base 59 | { 60 | BOOST_DEDUCED_TYPENAME Iterator::base_type operator()(Iterator iter) const 61 | { 62 | return iter.base(); 63 | } 64 | }; 65 | 66 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 67 | 68 | #undef BOOST_BIMAP_CONTAINER_ADAPTOR_IMPLEMENT_CONVERT_FACADE_FUNCTION 69 | 70 | 71 | } // namespace support 72 | } // namespace container_adaptor 73 | } // namespace bimaps 74 | } // namespace boost 75 | 76 | 77 | #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_ITERATOR_FACADE_CONVERTERS_HPP 78 | -------------------------------------------------------------------------------- /include/boost/bimap/container_adaptor/unordered_set_adaptor.hpp: -------------------------------------------------------------------------------- 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 container_adaptor/unordered_set_adaptor.hpp 10 | /// \brief Container adaptor to easily build a std::unordered_set signature compatible container. 11 | 12 | #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_SET_ADAPTOR_HPP 13 | #define BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_SET_ADAPTOR_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace boost { 26 | namespace bimaps { 27 | namespace container_adaptor { 28 | 29 | /// \brief Container adaptor to easily build a std::unordered_set signature compatible container. 30 | 31 | template 32 | < 33 | class Base, 34 | 35 | class Iterator, 36 | class ConstIterator, 37 | class LocalIterator, 38 | class ConstLocalIterator, 39 | 40 | class IteratorToBaseConverter = ::boost::mpl::na, 41 | class IteratorFromBaseConverter = ::boost::mpl::na, 42 | class LocalIteratorFromBaseConverter = ::boost::mpl::na, 43 | class ValueToBaseConverter = ::boost::mpl::na, 44 | class ValueFromBaseConverter = ::boost::mpl::na, 45 | class KeyToBaseConverter = ::boost::mpl::na, 46 | 47 | class FunctorsFromDerivedClasses = mpl::vector<> 48 | > 49 | class unordered_set_adaptor : 50 | 51 | public ::boost::bimaps::container_adaptor:: 52 | unordered_associative_container_adaptor 53 | < 54 | Base, 55 | Iterator, ConstIterator, LocalIterator, ConstLocalIterator, 56 | BOOST_DEDUCED_TYPENAME Iterator::value_type, 57 | IteratorToBaseConverter, IteratorFromBaseConverter, 58 | LocalIteratorFromBaseConverter, 59 | ValueToBaseConverter, ValueFromBaseConverter, 60 | KeyToBaseConverter, 61 | FunctorsFromDerivedClasses 62 | > 63 | { 64 | typedef ::boost::bimaps::container_adaptor:: 65 | unordered_associative_container_adaptor 66 | < 67 | Base, 68 | Iterator, ConstIterator, LocalIterator, ConstLocalIterator, 69 | BOOST_DEDUCED_TYPENAME Iterator::value_type, 70 | IteratorToBaseConverter, IteratorFromBaseConverter, 71 | LocalIteratorFromBaseConverter, 72 | ValueToBaseConverter, ValueFromBaseConverter, 73 | KeyToBaseConverter, 74 | FunctorsFromDerivedClasses 75 | 76 | > base_; 77 | 78 | // Access ----------------------------------------------------------------- 79 | 80 | public: 81 | 82 | explicit unordered_set_adaptor(Base & c) : 83 | base_(c) {} 84 | 85 | protected: 86 | 87 | typedef unordered_set_adaptor unordered_set_adaptor_; 88 | 89 | }; 90 | 91 | 92 | } // namespace container_adaptor 93 | } // namespace bimaps 94 | } // namespace boost 95 | 96 | 97 | #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_UNORDERED_SET_ADAPTOR_HPP 98 | 99 | -------------------------------------------------------------------------------- /include/boost/bimap/container_adaptor/vector_map_adaptor.hpp: -------------------------------------------------------------------------------- 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 container_adaptor/vector_map_adaptor.hpp 10 | /// \brief Container adaptor. 11 | 12 | #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_VECTOR_MAP_ADAPTOR_HPP 13 | #define BOOST_BIMAP_CONTAINER_ADAPTOR_VECTOR_MAP_ADAPTOR_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace boost { 29 | namespace bimaps { 30 | namespace container_adaptor { 31 | 32 | /// \brief Container adaptor. 33 | 34 | template 35 | < 36 | class Base, 37 | 38 | class Iterator, 39 | class ConstIterator, 40 | class ReverseIterator, 41 | class ConstReverseIterator, 42 | 43 | class IteratorToBaseConverter = ::boost::mpl::na, 44 | class IteratorFromBaseConverter = ::boost::mpl::na, 45 | class ReverseIteratorFromBaseConverter = ::boost::mpl::na, 46 | class ValueToBaseConverter = ::boost::mpl::na, 47 | class ValueFromBaseConverter = ::boost::mpl::na, 48 | 49 | class FunctorsFromDerivedClasses = mpl::vector<> 50 | > 51 | class vector_map_adaptor : 52 | 53 | public vector_adaptor 54 | < 55 | Base, 56 | Iterator, ConstIterator, ReverseIterator, ConstReverseIterator, 57 | IteratorToBaseConverter, IteratorFromBaseConverter, 58 | ReverseIteratorFromBaseConverter, 59 | ValueToBaseConverter, ValueFromBaseConverter, 60 | FunctorsFromDerivedClasses 61 | > 62 | { 63 | typedef vector_adaptor 64 | < 65 | Base, 66 | Iterator, ConstIterator, ReverseIterator, ConstReverseIterator, 67 | IteratorToBaseConverter, IteratorFromBaseConverter, 68 | ReverseIteratorFromBaseConverter, 69 | ValueToBaseConverter, ValueFromBaseConverter, 70 | FunctorsFromDerivedClasses 71 | 72 | > base_; 73 | 74 | // MetaData ------------------------------------------------------------- 75 | 76 | public: 77 | 78 | typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type key_type; 79 | typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::second_type data_type; 80 | typedef data_type mapped_type; 81 | 82 | // Access ----------------------------------------------------------------- 83 | 84 | public: 85 | 86 | vector_map_adaptor() {} 87 | 88 | explicit vector_map_adaptor(Base & c) : 89 | base_(c) {} 90 | 91 | protected: 92 | 93 | typedef vector_map_adaptor vector_map_adaptor_; 94 | 95 | }; 96 | 97 | 98 | } // namespace container_adaptor 99 | } // namespace bimaps 100 | } // namespace boost 101 | 102 | 103 | #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_VECTOR_MAP_ADAPTOR_HPP 104 | 105 | -------------------------------------------------------------------------------- /include/boost/bimap/detail/concept_tags.hpp: -------------------------------------------------------------------------------- 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 detail/concept_tags.hpp 10 | /// \brief Bimap tags and concepts 11 | 12 | #ifndef BOOST_BIMAP_DETAIL_CONCEPT_TAGS_HPP 13 | #define BOOST_BIMAP_DETAIL_CONCEPT_TAGS_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace boost { 26 | namespace bimaps { 27 | namespace detail { 28 | 29 | /// \brief Tag of {SetType}_of definition classes 30 | /** 31 | The {SetType}_of classes are derived from this class so it is easy to construct 32 | metafunctions. For example now is easy to create a is_set_type_of metafunction. 33 | **/ 34 | 35 | struct set_type_of_tag {}; 36 | 37 | /// \brief Tag of {SetType}_of_relation definition classes 38 | 39 | struct set_type_of_relation_tag {}; 40 | 41 | /// \brief Tag of {Side}_based identifiers 42 | 43 | struct side_based_tag : set_type_of_relation_tag {}; 44 | 45 | } // namespace detail 46 | 47 | 48 | /** \struct boost::bimaps::left_based 49 | \brief Tag to indicate that the main view will be based on the left side. 50 | 51 | This is convenient because the multi-index core will be more efficient. 52 | If possible use this options or the right based one. 53 | 54 | See also right_based. 55 | **/ 56 | 57 | /** \struct boost::bimaps::right_based 58 | \brief Tag to indicate that the main view will be based on the right side. 59 | 60 | This is convenient because the multi-index core will be more efficient. 61 | If possible use this options or the right based one. 62 | 63 | See also left_based. 64 | **/ 65 | 66 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 67 | 68 | struct left_based : ::boost::bimaps::detail::side_based_tag 69 | { 70 | // I run into troubles if I do not define bind for side based tags. 71 | // Maybe a more coherent way of binding the relation can be developed. 72 | template< class Relation > struct bind_to { typedef void type; }; 73 | 74 | typedef mpl::bool_ left_mutable_key; 75 | typedef mpl::bool_ right_mutable_key; 76 | }; 77 | 78 | struct right_based : ::boost::bimaps::detail::side_based_tag 79 | { 80 | // I run into troubles if I do not define bind for side based tags. 81 | // Maybe a more coherent way of binding the relation can be developed. 82 | template< class Relation > struct bind_to { typedef void type; }; 83 | 84 | typedef mpl::bool_ left_mutable_key; 85 | typedef mpl::bool_ right_mutable_key; 86 | }; 87 | 88 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 89 | 90 | typedef mpl::_ _relation; 91 | 92 | } // namespace bimaps 93 | } // namespace boost 94 | 95 | 96 | #endif // BOOST_BIMAP_DETAIL_CONCEPT_TAGS_HPP 97 | 98 | -------------------------------------------------------------------------------- /include/boost/bimap/detail/debug/static_error.hpp: -------------------------------------------------------------------------------- 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 detail/debug/static_error.hpp 10 | /// \brief Formatted compile time error 11 | 12 | #ifndef BOOST_BIMAP_DETAIL_DEBUG_STATIC_ERROR_HPP 13 | #define BOOST_BIMAP_DETAIL_DEBUG_STATIC_ERROR_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | // Easier way to call BOOST_MPL_ASSERT_MSG in class scope to generate 25 | // a static error. 26 | /*===========================================================================*/ 27 | #define BOOST_BIMAP_STATIC_ERROR(MESSAGE,VARIABLES) \ 28 | BOOST_MPL_ASSERT_MSG(false, \ 29 | BOOST_PP_CAT(BIMAP_STATIC_ERROR__,MESSAGE), \ 30 | VARIABLES) 31 | /*===========================================================================*/ 32 | 33 | 34 | 35 | #endif // BOOST_BIMAP_DETAIL_DEBUG_STATIC_ERROR_HPP 36 | -------------------------------------------------------------------------------- /include/boost/bimap/detail/generate_view_binder.hpp: -------------------------------------------------------------------------------- 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 detail/generate_view_binder.hpp 10 | /// \brief Define macros to help building the set type of definitions 11 | 12 | #ifndef BOOST_BIMAP_DETAIL_GENERATE_VIEW_BINDER_HPP 13 | #define BOOST_BIMAP_DETAIL_GENERATE_VIEW_BINDER_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | /*===========================================================================*/ 24 | #define BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER( \ 25 | \ 26 | MAP_VIEW_TYPE \ 27 | \ 28 | ) \ 29 | \ 30 | template< class Tag, class BimapType > \ 31 | struct map_view_bind \ 32 | { \ 33 | typedef MAP_VIEW_TYPE \ 34 | < \ 35 | Tag, \ 36 | BimapType \ 37 | \ 38 | > type; \ 39 | }; 40 | /*===========================================================================*/ 41 | 42 | 43 | /*===========================================================================*/ 44 | #define BOOST_BIMAP_GENERATE_SET_VIEW_BINDER( \ 45 | \ 46 | SET_VIEW_TYPE \ 47 | \ 48 | ) \ 49 | \ 50 | template< class IndexType > \ 51 | struct set_view_bind \ 52 | { \ 53 | typedef SET_VIEW_TYPE type; \ 54 | }; 55 | /*===========================================================================*/ 56 | 57 | 58 | #endif // BOOST_BIMAP_DETAIL_GENERATE_VIEW_BINDER_HPP 59 | -------------------------------------------------------------------------------- /include/boost/bimap/detail/is_set_type_of.hpp: -------------------------------------------------------------------------------- 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 detail/is_set_type_of.hpp 10 | /// \brief Is set type of and is set type of relation metafunctions. 11 | 12 | #ifndef BOOST_BIMAP_DETAIL_IS_SET_TYPE_OF_HPP 13 | #define BOOST_BIMAP_DETAIL_IS_SET_TYPE_OF_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | /** \struct boost::bimaps::detail::is_set_type_of 25 | 26 | \brief Type trait to check if a class is a set_type_of specification 27 | 28 | \code 29 | template< class Type > 30 | struct is_set_type_of : {true_|false_} {}; 31 | \endcode 32 | **/ 33 | 34 | /** \struct boost::bimaps::detail::is_set_type_of_relation 35 | 36 | \brief Type trait to check if a class is a set_type_of_relation specification 37 | 38 | \code 39 | template< class Type > 40 | struct is_set_type_of_relation : {true_|false_} {}; 41 | \endcode 42 | 43 | **/ 44 | 45 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 46 | 47 | namespace boost { 48 | namespace bimaps { 49 | namespace detail { 50 | 51 | template< class Type > 52 | struct is_set_type_of : 53 | is_base_of< set_type_of_tag, Type > {}; 54 | 55 | template< class Type > 56 | struct is_set_type_of_relation : 57 | is_base_of< set_type_of_relation_tag, Type > {}; 58 | 59 | } // namespace detail 60 | } // namespace bimaps 61 | } // namespace boost 62 | 63 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 64 | 65 | #endif // BOOST_BIMAP_DETAIL_IS_SET_TYPE_OF_HPP 66 | 67 | -------------------------------------------------------------------------------- /include/boost/bimap/detail/manage_bimap_key.hpp: -------------------------------------------------------------------------------- 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 detail/manage_bimap_key.hpp 10 | /// \brief Utility class to manage the set types of a bimap. 11 | 12 | #ifndef BOOST_BIMAP_DETAIL_MANAGE_BIMAP_KEY_HPP 13 | #define BOOST_BIMAP_DETAIL_MANAGE_BIMAP_KEY_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #include 27 | 28 | namespace boost { 29 | namespace bimaps { 30 | namespace detail { 31 | 32 | /** \struct boost::bimaps::detail::manage_bimap_key 33 | \brief Metafunction to manage the set types of a bimap. 34 | 35 | \code 36 | template< class Type > 37 | struct manage_bimap_key 38 | { 39 | typedef -SetType- type; 40 | } 41 | \endcode 42 | 43 | See also bimap, bimap_core. 44 | **/ 45 | 46 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 47 | 48 | template< class Type > 49 | struct manage_bimap_key 50 | { 51 | 52 | typedef BOOST_DEDUCED_TYPENAME 53 | 54 | mpl::eval_if< BOOST_DEDUCED_TYPENAME is_set_type_of< Type >::type, 55 | // { 56 | mpl::identity< Type >, 57 | // } 58 | // else 59 | // { 60 | // Default it to a set 61 | mpl::identity< set_of< Type > > 62 | // } 63 | 64 | >::type set_type; 65 | 66 | // Returns set_type and evaluate the concept_checked_type 67 | 68 | typedef BOOST_DEDUCED_TYPENAME mpl::if_c< true, set_type, 69 | BOOST_DEDUCED_TYPENAME set_type::lazy_concept_checked::type 70 | >::type type; 71 | }; 72 | 73 | 74 | 75 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 76 | 77 | } // namespace detail 78 | } // namespace bimaps 79 | } // namespace boost 80 | 81 | 82 | #endif // BOOST_BIMAP_DETAIL_MANAGE_BIMAP_KEY_HPP 83 | 84 | 85 | -------------------------------------------------------------------------------- /include/boost/bimap/detail/modifier_adaptor.hpp: -------------------------------------------------------------------------------- 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 detail/modifier_adaptor.hpp 10 | /// \brief A binary to unary functor relation modifier adaptor. 11 | 12 | #ifndef BOOST_BIMAP_DETAIL_MODIFIER_ADAPTOR_HPP 13 | #define BOOST_BIMAP_DETAIL_MODIFIER_ADAPTOR_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | namespace boost { 22 | namespace bimaps { 23 | namespace detail { 24 | 25 | /// \brief A binary to unary functor relation modifier adaptor. 26 | 27 | template 28 | < 29 | class Modifier, 30 | class NewArgument, 31 | class FirstExtractor, 32 | class SecondExtractor 33 | > 34 | struct relation_modifier_adaptor : 35 | Modifier, 36 | FirstExtractor, 37 | SecondExtractor 38 | { 39 | typedef NewArgument argument_type; 40 | typedef void result_type; 41 | 42 | relation_modifier_adaptor( const Modifier & m ) : Modifier(m) {} 43 | relation_modifier_adaptor( const Modifier & m, 44 | const FirstExtractor & fe, 45 | const SecondExtractor & se ) : 46 | Modifier(m), FirstExtractor(fe), SecondExtractor(se) {} 47 | 48 | void operator()( NewArgument & x ) const 49 | { 50 | Modifier::operator()( 51 | FirstExtractor ::operator()( x ), 52 | SecondExtractor::operator()( x ) 53 | ); 54 | } 55 | }; 56 | 57 | /// \brief A simple unary modifier adaptor. 58 | // This modifier is equivalent to bind( Modifier, bind( Extractor, _1 ) ) 59 | // It may be a good idea to start using Boost.Bind instead of it. 60 | 61 | template 62 | < 63 | class Modifier, 64 | class NewArgument, 65 | class Extractor 66 | > 67 | struct unary_modifier_adaptor : 68 | Modifier, 69 | Extractor 70 | { 71 | typedef NewArgument argument_type; 72 | typedef void result_type; 73 | 74 | unary_modifier_adaptor( const Modifier & m ) : Modifier(m) {} 75 | unary_modifier_adaptor( const Modifier & m, 76 | const Extractor & fe) : 77 | Modifier(m), Extractor(fe) {} 78 | 79 | void operator()( NewArgument & x ) const 80 | { 81 | Modifier::operator()( Extractor::operator()( x ) ); 82 | } 83 | }; 84 | 85 | 86 | } // namespace detail 87 | } // namespace bimap 88 | } // namespace boost 89 | 90 | 91 | #endif // BOOST_BIMAP_DETAIL_MODIFIER_ADAPTOR_HPP 92 | -------------------------------------------------------------------------------- /include/boost/bimap/detail/user_interface_config.hpp: -------------------------------------------------------------------------------- 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 detail/user_interface_config.hpp 10 | /// \brief General configuration directives 11 | 12 | 13 | #ifndef BOOST_BIMAP_DETAIL_USER_INTERFACE_CONFIG_HPP 14 | #define BOOST_BIMAP_DETAIL_USER_INTERFACE_CONFIG_HPP 15 | 16 | #if defined(_MSC_VER) 17 | #pragma once 18 | #endif 19 | 20 | #ifdef BOOST_BIMAP_DISABLE_SERIALIZATION 21 | #define BOOST_MULTI_INDEX_DISABLE_SERIALIZATION 22 | #endif 23 | 24 | #endif // BOOST_BIMAP_DETAIL_USER_INTERFACE_CONFIG_HPP 25 | -------------------------------------------------------------------------------- /include/boost/bimap/property_map/set_support.hpp: -------------------------------------------------------------------------------- 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 property_map/set_support.hpp 10 | /// \brief Support for the property map concept. 11 | 12 | #ifndef BOOST_BIMAP_PROPERTY_MAP_SET_SUPPORT_HPP 13 | #define BOOST_BIMAP_PROPERTY_MAP_SET_SUPPORT_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 26 | 27 | namespace boost { 28 | 29 | template struct property_traits; 30 | struct readable_property_map_tag; 31 | 32 | template< class Tag, class Bimap > 33 | struct property_traits< ::boost::bimaps::views::map_view > 34 | { 35 | typedef BOOST_DEDUCED_TYPENAME 36 | ::boost::bimaps::support::data_type_by::type value_type; 37 | typedef BOOST_DEDUCED_TYPENAME 38 | ::boost::bimaps::support:: key_type_by::type key_type; 39 | 40 | typedef readable_property_map_tag category; 41 | }; 42 | 43 | 44 | template< class Tag, class Bimap > 45 | const BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::data_type_by::type & 46 | get(const ::boost::bimaps::views::map_view & m, 47 | const BOOST_DEDUCED_TYPENAME 48 | ::boost::bimaps::support::key_type_by::type & key) 49 | { 50 | return m.at(key); 51 | } 52 | 53 | } // namespace boost 54 | 55 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 56 | 57 | #endif // BOOST_BIMAP_PROPERTY_MAP_SET_SUPPORT_HPP 58 | -------------------------------------------------------------------------------- /include/boost/bimap/property_map/unordered_set_support.hpp: -------------------------------------------------------------------------------- 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 property_map/unordered_set_support.hpp 10 | /// \brief Support for the property map concept. 11 | 12 | #ifndef BOOST_BIMAP_PROPERTY_MAP_UNORDERED_SET_SUPPORT_HPP 13 | #define BOOST_BIMAP_PROPERTY_MAP_UNORDERED_SET_SUPPORT_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 26 | 27 | namespace boost { 28 | 29 | template struct property_traits; 30 | struct readable_property_map_tag; 31 | 32 | template< class Tag, class Bimap > 33 | struct property_traits< ::boost::bimaps::views::unordered_map_view > 34 | { 35 | typedef BOOST_DEDUCED_TYPENAME 36 | ::boost::bimaps::support::data_type_by::type value_type; 37 | typedef BOOST_DEDUCED_TYPENAME 38 | ::boost::bimaps::support:: key_type_by::type key_type; 39 | 40 | typedef readable_property_map_tag category; 41 | }; 42 | 43 | 44 | template< class Tag, class Bimap > 45 | const BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::data_type_by::type & 46 | get(const ::boost::bimaps::views::unordered_map_view & m, 47 | const BOOST_DEDUCED_TYPENAME 48 | ::boost::bimaps::support::key_type_by::type & key) 49 | { 50 | return m.at(key); 51 | } 52 | 53 | } // namespace boost 54 | 55 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 56 | 57 | #endif // BOOST_BIMAP_PROPERTY_MAP_UNORDERED_SET_SUPPORT_HPP 58 | -------------------------------------------------------------------------------- /include/boost/bimap/relation/detail/mutant.hpp: -------------------------------------------------------------------------------- 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 relation/detail/mutant.hpp 10 | /// \brief Mutate functions to extract views of mutant classes. 11 | 12 | #ifndef BOOST_BIMAP_RELATION_DETAIL_MUTANT_HPP 13 | #define BOOST_BIMAP_RELATION_DETAIL_MUTANT_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace boost { 31 | namespace bimaps { 32 | namespace relation { 33 | 34 | /// \brief Relation details, mutant idiom and symmetrical metafunctions builders. 35 | 36 | namespace detail { 37 | 38 | //@{ 39 | /// \brief Converts a mutant class to a view with zero overhead. 40 | /** 41 | 42 | This function is a safe wrapper around reinterpret_cast. It checks at 43 | compile time that the desired view is supported by the mutant class. 44 | See also mutant, can_mutate_in. 45 | \ingroup mutant_group 46 | **/ 47 | 48 | 49 | template< class View, class Type > 50 | BOOST_DEDUCED_TYPENAME enable_if< mpl::not_< is_const< Type > >, 51 | 52 | View& 53 | 54 | >::type mutate( Type & m ) 55 | { 56 | BOOST_MPL_ASSERT(( 57 | ::boost::mpl::contains 58 | )); 59 | return *reinterpret_cast< View* >(boost::addressof(m)); 60 | } 61 | 62 | template< class View, class Type > 63 | BOOST_DEDUCED_TYPENAME enable_if< is_const< Type >, 64 | 65 | const View& 66 | 67 | >::type mutate( Type & m ) 68 | { 69 | BOOST_MPL_ASSERT(( 70 | ::boost::mpl::contains 71 | )); 72 | return *reinterpret_cast< const View* >(boost::addressof(m)); 73 | } 74 | 75 | //@} 76 | 77 | } // namespace detail 78 | } // namespace relation 79 | } // namespace bimaps 80 | } // namespace boost 81 | 82 | #endif // BOOST_BIMAP_RELATION_DETAIL_MUTANT_HPP 83 | 84 | -------------------------------------------------------------------------------- /include/boost/bimap/relation/detail/to_mutable_relation_functor.hpp: -------------------------------------------------------------------------------- 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 relation/detail/to_mutable_relation_functor.hpp 10 | /// \brief functors to convert types to mutable relations 11 | 12 | #ifndef BOOST_BIMAP_RELATION_DETAIL_TO_MUTABLE_RELATION_FUNCTOR_HPP 13 | #define BOOST_BIMAP_RELATION_DETAIL_TO_MUTABLE_RELATION_FUNCTOR_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace boost { 26 | namespace bimaps { 27 | namespace relation { 28 | namespace detail { 29 | 30 | /// \brief Functor used in map views 31 | 32 | template< class Tag, class Relation > 33 | struct pair_to_relation_functor 34 | { 35 | const Relation 36 | operator()(const BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support:: 37 | pair_type_by::type & p) const 38 | { 39 | return Relation(p); 40 | } 41 | }; 42 | 43 | template< class Tag, class TA, class TB, class Info > 44 | struct pair_to_relation_functor< 45 | Tag,::boost::bimaps::relation::mutant_relation > 46 | { 47 | typedef ::boost::bimaps::relation::mutant_relation Relation; 48 | 49 | Relation & 50 | operator()( BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support:: 51 | pair_type_by::type & p ) const 52 | { 53 | return ::boost::bimaps::relation::detail::mutate(p); 54 | } 55 | 56 | const Relation & 57 | operator()( const BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support:: 58 | pair_type_by::type & p) const 59 | { 60 | return ::boost::bimaps::relation::detail::mutate(p); 61 | } 62 | }; 63 | 64 | 65 | /// \brief Used in set views 66 | 67 | template< class Relation > 68 | struct get_mutable_relation_functor 69 | { 70 | const Relation 71 | operator()( const BOOST_DEDUCED_TYPENAME Relation::above_view & r ) const 72 | { 73 | return Relation(r); 74 | } 75 | }; 76 | 77 | template< class TA, class TB, class Info > 78 | struct get_mutable_relation_functor< ::boost::bimaps::relation::mutant_relation > 79 | { 80 | typedef ::boost::bimaps::relation::mutant_relation Relation; 81 | 82 | Relation & 83 | operator()( BOOST_DEDUCED_TYPENAME Relation::above_view & r ) const 84 | { 85 | return ::boost::bimaps::relation::detail::mutate(r); 86 | } 87 | 88 | const Relation & 89 | operator()( const BOOST_DEDUCED_TYPENAME Relation::above_view & r ) const 90 | { 91 | return ::boost::bimaps::relation::detail::mutate(r); 92 | } 93 | }; 94 | 95 | } // namespace detail 96 | } // namespace relation 97 | } // namespace bimaps 98 | } // namespace boost 99 | 100 | 101 | #endif // BOOST_BIMAP_RELATION_DETAIL_TO_MUTABLE_RELATION_FUNCTOR_HPP 102 | 103 | -------------------------------------------------------------------------------- /include/boost/bimap/relation/member_at.hpp: -------------------------------------------------------------------------------- 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 relation/member_at.hpp 10 | /// \brief Defines the tags for the member_at::side idiom 11 | 12 | #ifndef BOOST_BIMAP_RELATION_MEMBER_AT_HPP 13 | #define BOOST_BIMAP_RELATION_MEMBER_AT_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | namespace boost { 22 | namespace bimaps { 23 | namespace relation { 24 | 25 | /// \brief member_at::side idiom to access relation values and types using metaprogramming. 26 | /** 27 | 28 | This tags are used to specify which member you want to access when using a metafunction over 29 | a symmetrical type. The idea is to be able to write code like: 30 | 31 | \code 32 | result_of::get::type data = get(rel); 33 | \endcode 34 | 35 | The relation class supports this idiom even when the elements are tagged. This is useful 36 | because a user can decide to start tagging in any moment of the development. 37 | 38 | See also member_with_tag, is_tag_of_member_at_left, is_tag_of_member_at_right, get 39 | value_type_of, pair_by, pair_type_by. 40 | 41 | \ingroup relation_group 42 | **/ 43 | namespace member_at { 44 | 45 | /// \brief Member at left tag 46 | /** 47 | See also member_at, right. 48 | **/ 49 | 50 | struct left {}; 51 | 52 | /// \brief Member at right tag 53 | /** 54 | See also member_at, left. 55 | **/ 56 | 57 | struct right {}; 58 | 59 | /// \brief Member info tag 60 | /** 61 | See also member_at, left, right. 62 | **/ 63 | 64 | struct info {}; 65 | 66 | } 67 | 68 | } // namespace relation 69 | } // namespace bimaps 70 | } // namespace boost 71 | 72 | #endif // BOOST_BIMAP_RELATION_MEMBER_AT_HPP 73 | -------------------------------------------------------------------------------- /include/boost/bimap/relation/pair_layout.hpp: -------------------------------------------------------------------------------- 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 relation/pair_layout.hpp 10 | /// \brief Tags for pair layouts 11 | 12 | #ifndef BOOST_BIMAP_RELATION_PAIR_LAYOUT_HPP 13 | #define BOOST_BIMAP_RELATION_PAIR_LAYOUT_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | namespace boost { 22 | namespace bimaps { 23 | namespace relation { 24 | 25 | //@{ 26 | 27 | /// \brief Tag for normal layout. ( A,B -> A,B ) 28 | 29 | struct normal_layout {}; 30 | 31 | /// \brief Tag for mirror layout. ( A,B -> B,A ) 32 | 33 | struct mirror_layout {}; 34 | 35 | //@} 36 | 37 | /** \struct boost::bimaps::relation::inverse_layout 38 | \brief Metafunction to obtain the inverse of a layout. 39 | 40 | \code 41 | template< class Layout > 42 | struct inverse_layout 43 | { 44 | typedef {InverseLayout} type; 45 | }; 46 | \endcode 47 | 48 | See also normal_layout, mirror_layout. 49 | **/ 50 | 51 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 52 | 53 | template< class Layout > 54 | struct inverse_layout 55 | { 56 | typedef normal_layout type; 57 | }; 58 | 59 | template<> 60 | struct inverse_layout< normal_layout > 61 | { 62 | typedef mirror_layout type; 63 | }; 64 | 65 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 66 | 67 | } // namespace relation 68 | } // namespace bimaps 69 | } // namespace boost 70 | 71 | #endif // BOOST_BIMAP_RELATION_DETAIL_PAIR_LAYOUT_HPP 72 | 73 | -------------------------------------------------------------------------------- /include/boost/bimap/relation/support/data_extractor.hpp: -------------------------------------------------------------------------------- 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 relation/support/data_extractor.hpp 10 | /// \brief Data extraction functor. 11 | 12 | #ifndef BOOST_BIMAP_RELATION_SUPPORT_DATA_EXTRACTOR_HPP 13 | #define BOOST_BIMAP_RELATION_SUPPORT_DATA_EXTRACTOR_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | /** \struct boost::bimaps::relation::support::data_extractor 24 | 25 | \brief Data extraction functor. 26 | 27 | \ingroup relation_group 28 | **/ 29 | 30 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 31 | 32 | namespace boost { 33 | namespace bimaps { 34 | namespace relation { 35 | namespace support { 36 | 37 | template< class Tag, class Relation > 38 | struct data_extractor_implementation; 39 | 40 | template< class Relation > 41 | struct data_extractor_implementation< member_at::left, Relation > 42 | { 43 | typedef Relation argument_type; 44 | typedef BOOST_DEDUCED_TYPENAME Relation::left_value_type result_type; 45 | 46 | BOOST_DEDUCED_TYPENAME Relation::left_value_type const & 47 | operator()(Relation const & rel) const 48 | { 49 | return rel.left; 50 | } 51 | 52 | BOOST_DEDUCED_TYPENAME Relation::left_value_type & 53 | operator()(Relation & rel) const 54 | { 55 | return rel.left; 56 | } 57 | }; 58 | 59 | template< class Relation > 60 | struct data_extractor_implementation< member_at::right, Relation > 61 | { 62 | typedef Relation argument_type; 63 | typedef BOOST_DEDUCED_TYPENAME Relation::right_value_type result_type; 64 | 65 | BOOST_DEDUCED_TYPENAME Relation::right_value_type const & 66 | operator()(Relation const & rel) const 67 | { 68 | return rel.right; 69 | } 70 | 71 | BOOST_DEDUCED_TYPENAME Relation::right_value_type & 72 | operator()(Relation & rel) const 73 | { 74 | return rel.right; 75 | } 76 | }; 77 | 78 | template< class Tag, class Relation > 79 | struct data_extractor 80 | { 81 | typedef data_extractor_implementation 82 | < 83 | BOOST_DEDUCED_TYPENAME member_with_tag::type, 84 | Relation 85 | 86 | > type; 87 | }; 88 | 89 | template< class Relation > 90 | struct both_keys_extractor 91 | { 92 | typedef BOOST_DEDUCED_TYPENAME Relation::storage_base result_type; 93 | 94 | const result_type & operator()(const Relation & rel) const 95 | { 96 | return rel; 97 | } 98 | 99 | result_type & operator()( Relation & rel) const 100 | { 101 | return rel; 102 | } 103 | }; 104 | 105 | } // namespace support 106 | } // namespace relation 107 | } // namespace bimaps 108 | } // namespace boost 109 | 110 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 111 | 112 | #endif // BOOST_BIMAP_RELATION_SUPPORT_DATA_EXTRACTOR_HPP 113 | 114 | -------------------------------------------------------------------------------- /include/boost/bimap/relation/support/get_pair_functor.hpp: -------------------------------------------------------------------------------- 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 relation/support/get_pair_functor.hpp 10 | /// \brief get_pair_functor definition 11 | 12 | #ifndef BOOST_BIMAP_RELATION_SUPPORT_GET_PAIR_FUNCTOR_HPP 13 | #define BOOST_BIMAP_RELATION_SUPPORT_GET_PAIR_FUNCTOR_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | namespace boost { 24 | namespace bimaps { 25 | namespace relation { 26 | namespace support { 27 | 28 | /// \brief A Functor that takes a relation as a parameter an return the desired view. 29 | /** 30 | 31 | This functor is included to help users of the relation class when using 32 | stl algorithms. 33 | 34 | See also member_at, pair_by(). 35 | \ingroup relation_group 36 | 37 | **/ 38 | 39 | template< class Tag, class Relation > 40 | struct get_pair_functor 41 | { 42 | BOOST_DEDUCED_TYPENAME result_of::pair_by::type 43 | operator()( Relation & r ) const 44 | { 45 | return pair_by(r); 46 | } 47 | 48 | BOOST_DEDUCED_TYPENAME result_of::pair_by::type 49 | operator()( const Relation & r ) const 50 | { 51 | return pair_by(r); 52 | } 53 | }; 54 | 55 | 56 | /// \brief A Functor that takes a relation as a parameter an return the above view. 57 | /** 58 | 59 | \ingroup relation_group 60 | **/ 61 | 62 | template< class Relation > 63 | struct get_above_view_functor 64 | { 65 | BOOST_DEDUCED_TYPENAME Relation::above_view & 66 | operator()( Relation & r ) const 67 | { 68 | return r.get_view(); 69 | } 70 | 71 | const BOOST_DEDUCED_TYPENAME Relation::above_view & 72 | operator()( const Relation & r ) const 73 | { 74 | return r.get_view(); 75 | } 76 | }; 77 | 78 | } // namespace support 79 | } // namespace relation 80 | } // namespace bimaps 81 | } // namespace boost 82 | 83 | 84 | #endif // BOOST_BIMAP_RELATION_SUPPORT_GET_PAIR_FUNCTOR_HPP 85 | 86 | -------------------------------------------------------------------------------- /include/boost/bimap/relation/support/opposite_tag.hpp: -------------------------------------------------------------------------------- 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 relation/support/opposite_tag.hpp 10 | /// \brief Metafunction to obtain the opposite tag in a relation. 11 | 12 | #ifndef BOOST_BIMAP_RELATION_SUPPORT_OPPOSITE_TAG_HPP 13 | #define BOOST_BIMAP_RELATION_SUPPORT_OPPOSITE_TAG_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | /** \struct boost::bimaps::relation::support::opposite_tag 24 | 25 | \brief Metafunction to obtain the opposite tag in a relation. 26 | 27 | \code 28 | 29 | template< class Tag, class Relation > 30 | struct opposite_tag 31 | { 32 | typedef {OppositeTag} type; 33 | }; 34 | 35 | \endcode 36 | 37 | \ingroup relation_group 38 | **/ 39 | 40 | namespace boost { 41 | namespace bimaps { 42 | namespace relation { 43 | namespace support { 44 | 45 | // Implementation of const pair reference type by metafunction 46 | 47 | BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER 48 | ( 49 | opossite_tag, 50 | right_tag, 51 | left_tag 52 | ) 53 | 54 | } // namespace support 55 | } // namespace relation 56 | } // namespace bimaps 57 | } // namespace boost 58 | 59 | 60 | #endif // BOOST_BIMAP_RELATION_SUPPORT_OPPOSITE_TAG_HPP 61 | 62 | -------------------------------------------------------------------------------- /include/boost/bimap/relation/support/pair_type_by.hpp: -------------------------------------------------------------------------------- 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 relation/support/pair_type_by.hpp 10 | /// \brief pair_type_by metafunction 11 | 12 | #ifndef BOOST_BIMAP_RELATION_SUPPORT_PAIR_TYPE_BY_HPP 13 | #define BOOST_BIMAP_RELATION_SUPPORT_PAIR_TYPE_BY_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | /** \struct boost::bimaps::relation::support::pair_type_by 24 | 25 | \brief Metafunction to obtain the view type indexed by one of the sides. 26 | 27 | \code 28 | 29 | template< class Tag, class Relation > 30 | struct pair_type_by 31 | { 32 | typedef {signature-compatible with std::pair} type; 33 | }; 34 | 35 | \endcode 36 | 37 | See also member_at, pair_by(). 38 | \ingroup relation_group 39 | **/ 40 | 41 | namespace boost { 42 | namespace bimaps { 43 | namespace relation { 44 | namespace support { 45 | 46 | // Implementation of pair type by metafunction 47 | 48 | BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER 49 | ( 50 | pair_type_by, 51 | left_pair, 52 | right_pair 53 | ) 54 | 55 | } // namespace support 56 | } // namespace relation 57 | } // namespace bimaps 58 | } // namespace boost 59 | 60 | 61 | #endif // BOOST_BIMAP_RELATION_SUPPORT_PAIR_BY_TYPE_HPP 62 | 63 | -------------------------------------------------------------------------------- /include/boost/bimap/relation/support/value_type_of.hpp: -------------------------------------------------------------------------------- 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 relation/support/value_type_of.hpp 10 | /// \brief value_type_of metafunction 11 | 12 | #ifndef BOOST_BIMAP_RELATION_SUPPORT_VALUE_TYPE_OF_HPP 13 | #define BOOST_BIMAP_RELATION_SUPPORT_VALUE_TYPE_OF_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | /** \struct boost::bimaps::relation::support::value_type_of 24 | 25 | \brief Metafunction to obtain the value type of one of the sides. 26 | 27 | \code 28 | 29 | template< class Tag, class Relation > 30 | struct value_type_of 31 | { 32 | typedef typename Relation::{side}_type type; 33 | }; 34 | 35 | \endcode 36 | 37 | See also member_at, get(). 38 | \ingroup relation_group 39 | **/ 40 | 41 | namespace boost { 42 | namespace bimaps { 43 | namespace relation { 44 | namespace support { 45 | 46 | // Metafunction value_type_of 47 | /* 48 | 49 | template< class Tag, class Relation > 50 | struct value_type_of 51 | { 52 | typedef -unspecified- type; 53 | }; 54 | 55 | */ 56 | 57 | BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER 58 | ( 59 | value_type_of, 60 | left_value_type, 61 | right_value_type 62 | ) 63 | 64 | // Add support for info tags to value_type_of 65 | 66 | template< class Tag, class SymmetricType > 67 | struct value_type_of 68 | < 69 | Tag, SymmetricType, 70 | BOOST_DEDUCED_TYPENAME enable_if 71 | < 72 | ::boost::bimaps::relation::support::is_tag_of_member_at_info 73 | < 74 | Tag, 75 | SymmetricType 76 | > 77 | 78 | >::type 79 | > 80 | { 81 | typedef BOOST_DEDUCED_TYPENAME SymmetricType::info_type type; 82 | }; 83 | 84 | } // namespace support 85 | } // namespace relation 86 | } // namespace bimaps 87 | } // namespace boost 88 | 89 | 90 | #endif // BOOST_BIMAP_RELATION_SUPPORT_VALUE_TYPE_OF_HPP 91 | 92 | -------------------------------------------------------------------------------- /include/boost/bimap/relation/symmetrical_base.hpp: -------------------------------------------------------------------------------- 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 relation/symmetrical_base.hpp 10 | /// \brief Base class for symmetrical types 11 | 12 | #ifndef BOOST_BIMAP_RELATION_SYMMETRICAL_BASE_HPP 13 | #define BOOST_BIMAP_RELATION_SYMMETRICAL_BASE_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | // Boost.Bimap 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | 31 | namespace boost { 32 | namespace bimaps { 33 | namespace relation { 34 | 35 | /// \brief Base of symmetrical tagged types. 36 | /** 37 | 38 | **/ 39 | 40 | template< class TA, class TB, bool force_mutable = false > 41 | class symmetrical_base 42 | { 43 | 44 | public: 45 | 46 | typedef BOOST_DEDUCED_TYPENAME tags::support::default_tagged 47 | < 48 | TA, 49 | member_at::left 50 | 51 | >::type tagged_left_type; 52 | 53 | typedef BOOST_DEDUCED_TYPENAME tags::support::default_tagged 54 | < 55 | TB, 56 | member_at::right 57 | 58 | >::type tagged_right_type; 59 | 60 | public: 61 | 62 | //@{ 63 | /// The type stored in the relation 64 | 65 | typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< force_mutable, 66 | 67 | BOOST_DEDUCED_TYPENAME ::boost::remove_const< 68 | BOOST_DEDUCED_TYPENAME tagged_left_type::value_type >::type, 69 | BOOST_DEDUCED_TYPENAME tagged_left_type::value_type 70 | 71 | >::type left_value_type; 72 | 73 | typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< force_mutable, 74 | 75 | BOOST_DEDUCED_TYPENAME ::boost::remove_const< 76 | BOOST_DEDUCED_TYPENAME tagged_right_type::value_type >::type, 77 | BOOST_DEDUCED_TYPENAME tagged_right_type::value_type 78 | 79 | >::type right_value_type; 80 | //@} 81 | 82 | //@{ 83 | /// The tag of the member. By default it is \c member_at::{side} 84 | typedef BOOST_DEDUCED_TYPENAME tagged_left_type ::tag left_tag; 85 | typedef BOOST_DEDUCED_TYPENAME tagged_right_type::tag right_tag; 86 | //@} 87 | }; 88 | 89 | 90 | 91 | } // namespace relation 92 | } // namespace bimaps 93 | } // namespace boost 94 | 95 | 96 | #endif // BOOST_BIMAP_RELATION_SYMMETRICAL_BASE_HPP 97 | 98 | -------------------------------------------------------------------------------- /include/boost/bimap/support/data_type_by.hpp: -------------------------------------------------------------------------------- 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 support/data_type_by.hpp 10 | /// \brief Metafunction to access the data types of a bimap 11 | 12 | #ifndef BOOST_BIMAP_SUPPORT_DATA_TYPE_BY_HPP 13 | #define BOOST_BIMAP_SUPPORT_DATA_TYPE_BY_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | /** \struct boost::bimaps::support::data_type_by 24 | 25 | \brief Metafunction to obtain the data type of one of the sides in a bimap 26 | 27 | The tag parameter can be either a user defined tag or \c member_at::{side}. 28 | This is the actual data type stored in the bimap. 29 | \code 30 | 31 | template< class Tag, class Bimap > 32 | struct data_type_by 33 | { 34 | typedef typename Bimap::{side}_data_type type; 35 | }; 36 | 37 | \endcode 38 | 39 | The following holds: 40 | 41 | \code 42 | 43 | BOOST_STATIC_ASSERT 44 | ( 45 | is_same< data_type_by< member_at::left, bimap >::type, A >::value 46 | ) 47 | 48 | \endcode 49 | 50 | See also member_at. 51 | \ingroup bimap_group 52 | **/ 53 | 54 | namespace boost { 55 | namespace bimaps { 56 | namespace support { 57 | 58 | // Implementation of data type of metafunction 59 | 60 | BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER 61 | ( 62 | data_type_by, 63 | left_data_type, 64 | right_data_type 65 | ) 66 | 67 | } // namespace support 68 | } // namespace bimaps 69 | } // namespace boost 70 | 71 | 72 | #endif // BOOST_BIMAP_SUPPORT_DATA_TYPE_BY_HPP 73 | 74 | -------------------------------------------------------------------------------- /include/boost/bimap/support/key_type_by.hpp: -------------------------------------------------------------------------------- 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 support/key_type_by.hpp 10 | /// \brief Metafunction to access the set types of a bimap 11 | 12 | #ifndef BOOST_BIMAP_SUPPORT_KEY_TYPE_BY_HPP 13 | #define BOOST_BIMAP_SUPPORT_KEY_TYPE_BY_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | /** \struct boost::bimaps::support::key_type_by 24 | 25 | \brief Metafunction to obtain the key type of one of the sides in a bimap 26 | 27 | The tag parameter can be either a user defined tag or \c member_at::{side}. 28 | The returned type is one of the {SetType}_of definition classes. 29 | 30 | \code 31 | 32 | template< class Tag, class Bimap > 33 | struct key_type_by 34 | { 35 | typedef typename Bimap::{side}_key_type type; 36 | }; 37 | 38 | \endcode 39 | 40 | See also member_at. 41 | \ingroup bimap_group 42 | **/ 43 | 44 | 45 | namespace boost { 46 | namespace bimaps { 47 | namespace support { 48 | 49 | // Implementation of key type type of metafunction 50 | 51 | BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER 52 | ( 53 | key_type_by, 54 | left_key_type, 55 | right_key_type 56 | ) 57 | 58 | 59 | } // namespace support 60 | } // namespace bimaps 61 | } // namespace boost 62 | 63 | #endif // BOOST_BIMAP_SUPPORT_KEY_TYPE_BY_HPP 64 | 65 | -------------------------------------------------------------------------------- /include/boost/bimap/support/lambda.hpp: -------------------------------------------------------------------------------- 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 support/lambda.hpp 10 | /// \brief Placeholders definition to help in bimap modify function 11 | 12 | #ifndef BOOST_BIMAP_SUPPORT_LAMBDA_HPP 13 | #define BOOST_BIMAP_SUPPORT_LAMBDA_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | namespace boost { 24 | namespace bimaps { 25 | 26 | namespace { 27 | 28 | /* 29 | boost::lambda::placeholder1_type & _first = boost::lambda::_1; 30 | boost::lambda::placeholder2_type & _second = boost::lambda::_2; 31 | 32 | boost::lambda::placeholder1_type & _left = boost::lambda::_1; 33 | boost::lambda::placeholder2_type & _right = boost::lambda::_2; 34 | */ 35 | 36 | boost::lambda::placeholder1_type & _key = boost::lambda::_1; 37 | boost::lambda::placeholder1_type & _data = boost::lambda::_1; 38 | 39 | } 40 | 41 | } // namespace bimaps 42 | } // namespace boost 43 | 44 | 45 | #endif // BOOST_BIMAP_SUPPORT_LAMBDA_HPP 46 | 47 | -------------------------------------------------------------------------------- /include/boost/bimap/support/map_type_by.hpp: -------------------------------------------------------------------------------- 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 support/map_type_by.hpp 10 | /// \brief Metafunction to access the map view types of a bimap 11 | 12 | #ifndef BOOST_BIMAP_SUPPORT_MAP_TYPE_BY_HPP 13 | #define BOOST_BIMAP_SUPPORT_MAP_TYPE_BY_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | /** \struct boost::bimaps::support::map_type_by 24 | 25 | \brief Metafunction to obtain the map view type of a bimap indexed by one of the sides. 26 | 27 | The tag parameter can be either a user defined tag or \c member_at::{side}. 28 | The returned type is signature-compatible with std::pair. 29 | 30 | \code 31 | 32 | template< class Tag, class Bimap > 33 | struct map_type_by 34 | { 35 | typedef typename Bimap::{side}_map_type type; 36 | }; 37 | 38 | \endcode 39 | 40 | See also member_at. 41 | \ingroup bimap_group 42 | **/ 43 | 44 | namespace boost { 45 | namespace bimaps { 46 | namespace support { 47 | 48 | // Implementation of map type by metafunction 49 | 50 | BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER 51 | ( 52 | map_type_by, 53 | left_map, 54 | right_map 55 | ) 56 | 57 | 58 | 59 | } // namespace support 60 | } // namespace bimaps 61 | } // namespace boost 62 | 63 | 64 | #endif // BOOST_BIMAP_SUPPORT_MAP_TYPE_BY_HPP 65 | 66 | -------------------------------------------------------------------------------- /include/boost/bimap/support/value_type_by.hpp: -------------------------------------------------------------------------------- 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 support/value_type_by.hpp 10 | /// \brief Metafunction to access the value types (std::pair compatibles) of a bimap 11 | 12 | #ifndef BOOST_BIMAP_SUPPORT_VALUE_TYPE_BY_HPP 13 | #define BOOST_BIMAP_SUPPORT_VALUE_TYPE_BY_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | /** \struct boost::bimaps::support::value_type_by 24 | 25 | \brief Metafunction to obtain the value type of a bimap indexed by one of the sides. 26 | 27 | The tag parameter can be either a user defined tag or \c member_at::{side}. 28 | The returned type is signature-compatible with std::pair. 29 | 30 | \code 31 | 32 | template< class Tag, class Bimap > 33 | struct value_type_by 34 | { 35 | typedef typename Bimap::{side}_value_type type; 36 | }; 37 | 38 | \endcode 39 | 40 | See also member_at. 41 | \ingroup bimap_group 42 | **/ 43 | 44 | namespace boost { 45 | namespace bimaps { 46 | namespace support { 47 | 48 | // Implementation of value type by metafunction 49 | 50 | BOOST_BIMAP_SYMMETRIC_METADATA_ACCESS_BUILDER 51 | ( 52 | value_type_by, 53 | left_value_type, 54 | right_value_type 55 | ) 56 | 57 | 58 | 59 | } // namespace support 60 | } // namespace bimaps 61 | } // namespace boost 62 | 63 | 64 | #endif // BOOST_BIMAP_SUPPORT_VALUE_TYPE_BY_HPP 65 | 66 | -------------------------------------------------------------------------------- /include/boost/bimap/tags/support/apply_to_value_type.hpp: -------------------------------------------------------------------------------- 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 tags/support/apply_to_value_type.hpp 10 | /// \brief Similar to mpl::apply but for tagged types. 11 | 12 | #ifndef BOOST_BIMAP_TAGS_SUPPORT_APPLY_TO_VALUE_TYPE_HPP 13 | #define BOOST_BIMAP_TAGS_SUPPORT_APPLY_TO_VALUE_TYPE_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | /** \struct boost::bimaps::tags::support::apply_to_value_type 25 | \brief Higger order metafunction similar to mpl::apply but for tagged types. 26 | 27 | \code 28 | template< class Metafunction, class TaggedType > 29 | struct apply_to_value_type 30 | { 31 | typedef tagged 32 | < 33 | Metafuntion< value_type_of< TaggedType >::type >::type, 34 | tag_of< TaggedType >::type 35 | 36 | > type; 37 | }; 38 | \endcode 39 | 40 | This higher order metafunctions is very useful, and it can be used with lambda 41 | expressions. 42 | 43 | See also tagged. 44 | **/ 45 | 46 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 47 | 48 | namespace boost { 49 | namespace bimaps { 50 | namespace tags { 51 | namespace support { 52 | 53 | template < class F, class TaggedType > 54 | struct apply_to_value_type; 55 | 56 | template < class F, class ValueType, class Tag > 57 | struct apply_to_value_type > 58 | { 59 | typedef BOOST_DEDUCED_TYPENAME mpl::apply< F, ValueType >::type new_value_type; 60 | typedef tagged< new_value_type, Tag > type; 61 | }; 62 | 63 | } // namespace support 64 | } // namespace tags 65 | } // namespace bimaps 66 | } // namespace boost 67 | 68 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 69 | 70 | #endif // BOOST_BIMAP_TAGS_SUPPORT_APPLY_TO_VALUE_TYPE_HPP 71 | -------------------------------------------------------------------------------- /include/boost/bimap/tags/support/default_tagged.hpp: -------------------------------------------------------------------------------- 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 tags/support/default_tagged.hpp 10 | /// \brief Weak tagging 11 | 12 | #ifndef BOOST_BIMAP_TAGS_SUPPORT_DEFAULT_TAGGED_HPP 13 | #define BOOST_BIMAP_TAGS_SUPPORT_DEFAULT_TAGGED_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | /** \struct boost::bimaps::tags::support::default_tagged 24 | \brief Weak tagging metafunction 25 | 26 | \code 27 | template< class Type, class Tag > 28 | struct default_tagged 29 | { 30 | typedef {TaggedType} type; 31 | }; 32 | \endcode 33 | 34 | If the type is not tagged, this metafunction returns a tagged type with the 35 | default tag. If it is tagged, the returns the type unchanged. 36 | 37 | See also tagged, overwrite_tagged. 38 | **/ 39 | 40 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 41 | 42 | namespace boost { 43 | namespace bimaps { 44 | namespace tags { 45 | namespace support { 46 | 47 | 48 | // Default Tagging 49 | // A metafunction that create a tagged type with a default tag value. 50 | 51 | template< class Type, class DefaultTag > 52 | struct default_tagged 53 | { 54 | typedef tagged type; 55 | }; 56 | 57 | template< class Type, class OldTag, class NewTag > 58 | struct default_tagged< tagged< Type, OldTag >, NewTag > 59 | { 60 | typedef tagged type; 61 | }; 62 | 63 | } // namespace support 64 | } // namespace tags 65 | } // namespace bimaps 66 | } // namespace boost 67 | 68 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 69 | 70 | #endif // BOOST_BIMAP_TAGS_SUPPORT_DEFAULT_TAGGED_HPP 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /include/boost/bimap/tags/support/is_tagged.hpp: -------------------------------------------------------------------------------- 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 tags/support/is_tagged.hpp 10 | /// \brief type_traits extension 11 | 12 | #ifndef BOOST_BIMAP_TAGS_SUPPORT_IS_TAGGED_HPP 13 | #define BOOST_BIMAP_TAGS_SUPPORT_IS_TAGGED_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | /** \struct boost::bimaps::tags::support::is_tagged 25 | \brief Type trait to check if a type is tagged. 26 | 27 | \code 28 | template< class Type > 29 | struct is_tagged 30 | { 31 | typedef {mpl::true_/mpl::false_} type; 32 | }; 33 | \endcode 34 | 35 | See also tagged. 36 | **/ 37 | 38 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 39 | 40 | namespace boost { 41 | namespace bimaps { 42 | namespace tags { 43 | namespace support { 44 | 45 | 46 | // is_tagged metafunction 47 | 48 | template< class Type > 49 | struct is_tagged : 50 | ::boost::mpl::false_ {}; 51 | 52 | template< class Type, class Tag > 53 | struct is_tagged< tagged< Type, Tag > > : 54 | ::boost::mpl::true_ {}; 55 | 56 | } // namespace support 57 | } // namespace tags 58 | } // namespace bimaps 59 | } // namespace boost 60 | 61 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 62 | 63 | #endif // BOOST_BIMAP_TAGS_SUPPORT_IS_TAGGED_HPP 64 | 65 | -------------------------------------------------------------------------------- /include/boost/bimap/tags/support/overwrite_tagged.hpp: -------------------------------------------------------------------------------- 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 tags/support/overwrite_tagged.hpp 10 | /// \brief Hard tagging 11 | 12 | #ifndef BOOST_BIMAP_TAGS_SUPPORT_OVERWRITE_TAGGED_HPP 13 | #define BOOST_BIMAP_TAGS_SUPPORT_OVERWRITE_TAGGED_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | /** \struct boost::bimaps::tags::support::overwrite_tagged 24 | \brief Hard tagging metafunction 25 | 26 | \code 27 | template< class Type, class Tag > 28 | struct overwrite_tagged 29 | { 30 | typedef {TaggedType} type; 31 | }; 32 | \endcode 33 | 34 | If the type is not tagged, this metafunction returns a tagged type with the 35 | passed tag. If it is tagged it returns a new tagged type with the tag replaced 36 | by the one passed as a parameter. 37 | 38 | See also tagged, default_tagged. 39 | **/ 40 | 41 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 42 | 43 | namespace boost { 44 | namespace bimaps { 45 | namespace tags { 46 | namespace support { 47 | 48 | 49 | // Change the tag 50 | 51 | template< class Type, class NewTag > 52 | struct overwrite_tagged 53 | { 54 | typedef tagged type; 55 | }; 56 | 57 | template< class Type, class OldTag, class NewTag > 58 | struct overwrite_tagged< tagged< Type, OldTag >, NewTag > 59 | { 60 | typedef tagged type; 61 | }; 62 | 63 | 64 | } // namespace support 65 | } // namespace tags 66 | } // namespace bimaps 67 | } // namespace boost 68 | 69 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 70 | 71 | #endif // BOOST_BIMAP_TAGS_SUPPORT_OVERWRITE_TAGGED_HPP 72 | 73 | 74 | -------------------------------------------------------------------------------- /include/boost/bimap/tags/support/tag_of.hpp: -------------------------------------------------------------------------------- 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 tags/support/tag_of.hpp 10 | /// \brief Safe way to access the tag of a type 11 | 12 | #ifndef BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP 13 | #define BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | /** \struct boost::bimaps::tags::support::tag_of 25 | \brief Metafunction to obtain the tag of a type. 26 | 27 | \code 28 | template< class TaggedType > 29 | struct tag_of 30 | { 31 | typedef {Tag} type; 32 | }; 33 | \endcode 34 | 35 | If the type is not tagged you will get a compile timer error with the following message: 36 | 37 | \verbatim 38 | USING_TAG_OF_WITH_AN_UNTAGGED_TYPE, TaggedType 39 | \endverbatim 40 | 41 | See also tagged, value_type_of. 42 | **/ 43 | 44 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 45 | 46 | namespace boost { 47 | namespace bimaps { 48 | namespace tags { 49 | namespace support { 50 | 51 | 52 | // tag_of metafunction 53 | 54 | template< class Type > 55 | struct tag_of 56 | { 57 | BOOST_BIMAP_STATIC_ERROR( USING_TAG_OF_WITH_AN_UNTAGGED_TYPE, (Type) ); 58 | }; 59 | 60 | template< class Type, class Tag > 61 | struct tag_of< tagged< Type, Tag > > 62 | { 63 | typedef Tag type; 64 | }; 65 | 66 | 67 | } // namespace support 68 | } // namespace tags 69 | } // namespace bimaps 70 | } // namespace boost 71 | 72 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 73 | 74 | #endif // BOOST_BIMAP_TAGS_SUPPORT_TAG_OF_HPP 75 | 76 | -------------------------------------------------------------------------------- /include/boost/bimap/tags/support/value_type_of.hpp: -------------------------------------------------------------------------------- 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 tags/support/value_type_of.hpp 10 | /// \brief Consistent way to access the value type of a tagged or untagged type. 11 | 12 | #ifndef BOOST_BIMAP_TAGS_SUPPORT_VALUE_TYPE_OF_HPP 13 | #define BOOST_BIMAP_TAGS_SUPPORT_VALUE_TYPE_OF_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | 23 | /** \struct boost::bimaps::tags::support::value_type_of 24 | \brief Metafunction to work with tagged and untagged type uniformly 25 | 26 | \code 27 | template< class Type > 28 | struct value_type_of 29 | { 30 | typedef {UntaggedType} type; 31 | }; 32 | \endcode 33 | 34 | If the type is tagged this metafunction returns Type::value_type, and if it is not 35 | tagged it return the same type. This allows to work consistently with tagged and 36 | untagged types. 37 | 38 | See also tagged, tag_of. 39 | **/ 40 | 41 | #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 42 | 43 | 44 | namespace boost { 45 | namespace bimaps { 46 | namespace tags { 47 | namespace support { 48 | 49 | 50 | // value_type_of metafunction 51 | 52 | template< class Type > 53 | struct value_type_of 54 | { 55 | typedef Type type; 56 | }; 57 | 58 | template< class Type, class Tag > 59 | struct value_type_of< tagged< Type, Tag > > 60 | { 61 | typedef Type type; 62 | }; 63 | 64 | 65 | } // namespace support 66 | } // namespace tags 67 | } // namespace bimaps 68 | } // namespace boost 69 | 70 | #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES 71 | 72 | #endif // BOOST_BIMAP_TAGS_SUPPORT_VALUE_TYPE_OF_HPP 73 | 74 | 75 | -------------------------------------------------------------------------------- /include/boost/bimap/views/set_view.hpp: -------------------------------------------------------------------------------- 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 views/set_view.hpp 10 | /// \brief View of a bimap that is signature compatible with std::set. 11 | 12 | #ifndef BOOST_BIMAP_VIEWS_SET_VIEW_HPP 13 | #define BOOST_BIMAP_VIEWS_SET_VIEW_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | namespace boost { 25 | namespace bimaps { 26 | namespace views { 27 | 28 | /// \brief View of a bimap that is signature compatible with std::set. 29 | /** 30 | 31 | This class uses container_adaptor and iterator_adaptor to wrapped a index of the 32 | multi_index bimap core so it can be used as a std::set. 33 | 34 | See also const_set_view. 35 | **/ 36 | 37 | template< class CoreIndex > 38 | class set_view 39 | : 40 | public BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR( 41 | set_adaptor, 42 | CoreIndex, 43 | reverse_iterator, const_reverse_iterator 44 | ), 45 | 46 | public ::boost::bimaps::detail:: 47 | set_view_base< set_view< CoreIndex >, CoreIndex > 48 | { 49 | typedef BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR( 50 | set_adaptor, 51 | CoreIndex, 52 | reverse_iterator, const_reverse_iterator 53 | 54 | ) base_; 55 | 56 | BOOST_BIMAP_SET_VIEW_BASE_FRIEND(set_view,CoreIndex) 57 | 58 | public: 59 | 60 | set_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) : base_(c) {} 61 | 62 | /* 63 | template< class LowerBounder, class UpperBounder > 64 | std::pair 66 | range(LowerBounder lower,UpperBounder upper) const 67 | { 68 | return this->base().range( 69 | 70 | ::boost::bimaps::container_adaptor::detail::unary_check_adaptor 71 | < 72 | LowerBounder, 73 | BOOST_DEDUCED_TYPENAME base_::base_type::value_type, 74 | BOOST_DEDUCED_TYPENAME base_::value_from_base 75 | 76 | >( lower, this->template functor< 77 | BOOST_DEDUCED_TYPENAME base_::value_from_base>() ), 78 | 79 | ::boost::bimaps::container_adaptor::detail::unary_check_adaptor 80 | < 81 | UpperBounder, 82 | BOOST_DEDUCED_TYPENAME base_::base_type::value_type, 83 | BOOST_DEDUCED_TYPENAME base_::value_from_base 84 | 85 | >( upper, this->template functor< 86 | BOOST_DEDUCED_TYPENAME base_::value_from_base>() ) 87 | 88 | ); 89 | } 90 | */ 91 | 92 | set_view & operator=(const set_view & v) 93 | { 94 | this->base() = v.base(); 95 | return *this; 96 | } 97 | }; 98 | 99 | 100 | } // namespace views 101 | } // namespace bimaps 102 | } // namespace boost 103 | 104 | #endif // BOOST_BIMAP_VIEWS_SET_VIEW_HPP 105 | 106 | 107 | -------------------------------------------------------------------------------- /include/boost/bimap/views/unconstrained_map_view.hpp: -------------------------------------------------------------------------------- 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 views/unconstrained_map_view.hpp 10 | /// \brief Unconstrained view of a side of a bimap. 11 | 12 | #ifndef BOOST_BIMAP_VIEWS_UNCONSTRAINED_MAP_VIEW_HPP 13 | #define BOOST_BIMAP_VIEWS_UNCONSTRAINED_MAP_VIEW_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | namespace boost { 22 | namespace bimaps { 23 | namespace views { 24 | 25 | /// \brief Unconstrained view of a side of a bimap. 26 | 27 | template< class Tag, class BimapType> 28 | class unconstrained_map_view 29 | { 30 | public: 31 | template< class T > 32 | unconstrained_map_view(const T &) {} 33 | 34 | typedef void iterator; 35 | typedef void const_iterator; 36 | typedef void reference; 37 | typedef void const_reference; 38 | typedef void info_type; 39 | }; 40 | 41 | } // namespace views 42 | } // namespace bimaps 43 | } // namespace boost 44 | 45 | #endif // BOOST_BIMAP_VIEWS_UNCONSTRAINED_MAP_VIEW_HPP 46 | 47 | -------------------------------------------------------------------------------- /include/boost/bimap/views/unconstrained_set_view.hpp: -------------------------------------------------------------------------------- 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 views/unconstrained_set_view.hpp 10 | /// \brief Unconstrained view of a bimap. 11 | 12 | #ifndef BOOST_BIMAP_VIEWS_UNCONSTRAINED_SET_VIEW_HPP 13 | #define BOOST_BIMAP_VIEWS_UNCONSTRAINED_SET_VIEW_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | namespace boost { 22 | namespace bimaps { 23 | namespace views { 24 | 25 | /// \brief Unconstrained view of a bimap. 26 | 27 | template< class CoreIndex > 28 | class unconstrained_set_view 29 | { 30 | public: 31 | template< class T > 32 | unconstrained_set_view(const T &) {} 33 | 34 | typedef void iterator; 35 | typedef void const_iterator; 36 | }; 37 | 38 | } // namespace views 39 | } // namespace bimaps 40 | } // namespace boost 41 | 42 | #endif // BOOST_BIMAP_VIEWS_UNCONSTRAINED_SET_VIEW_HPP 43 | -------------------------------------------------------------------------------- /include/boost/bimap/views/unordered_multiset_view.hpp: -------------------------------------------------------------------------------- 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 views/unordered_multiset_view.hpp 10 | /// \brief View of a bimap that is signature compatible with tr1::unordered_multiset. 11 | 12 | #ifndef BOOST_BIMAP_VIEWS_UNORDERED_MULTISET_VIEW_HPP 13 | #define BOOST_BIMAP_VIEWS_UNORDERED_MULTISET_VIEW_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace boost { 26 | namespace bimaps { 27 | namespace views { 28 | 29 | /// \brief View of a bimap that is signature compatible with std::unordered_multiset. 30 | /** 31 | 32 | This class uses container_adaptor and iterator_adaptor to wrapped a index of the 33 | multi_index bimap core so it can be used as a std::unordered_multiset. 34 | 35 | See also const_unordered_multiset_view. 36 | **/ 37 | 38 | template< class CoreIndex > 39 | class unordered_multiset_view 40 | : 41 | public BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR( 42 | unordered_multiset_adaptor, 43 | CoreIndex, 44 | local_iterator, 45 | const_local_iterator 46 | 47 | ), 48 | 49 | public ::boost::bimaps::detail:: 50 | set_view_base< unordered_multiset_view< CoreIndex >, CoreIndex > 51 | { 52 | BOOST_BIMAP_SET_VIEW_BASE_FRIEND(unordered_multiset_view,CoreIndex) 53 | 54 | typedef BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR( 55 | unordered_multiset_adaptor, 56 | CoreIndex, 57 | local_iterator, 58 | const_local_iterator 59 | 60 | ) base_; 61 | 62 | public: 63 | 64 | unordered_multiset_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) 65 | : base_(c) {} 66 | 67 | BOOST_BIMAP_NON_UNIQUE_VIEW_INSERT_FUNCTIONS 68 | 69 | unordered_multiset_view & operator=(const unordered_multiset_view & v) 70 | { 71 | this->base() = v.base(); 72 | return *this; 73 | } 74 | }; 75 | 76 | 77 | } // namespace views 78 | } // namespace bimaps 79 | } // namespace boost 80 | 81 | #endif // BOOST_BIMAP_VIEWS_UNORDERED_MULTISET_VIEW_HPP 82 | 83 | 84 | -------------------------------------------------------------------------------- /include/boost/bimap/views/unordered_set_view.hpp: -------------------------------------------------------------------------------- 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 views/unordered_set_view.hpp 10 | /// \brief View of a bimap that is signature compatible with tr1::unordered_set. 11 | 12 | #ifndef BOOST_BIMAP_VIEWS_UNORDERED_SET_VIEW_HPP 13 | #define BOOST_BIMAP_VIEWS_UNORDERED_SET_VIEW_HPP 14 | 15 | #if defined(_MSC_VER) 16 | #pragma once 17 | #endif 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | namespace boost { 25 | namespace bimaps { 26 | namespace views { 27 | 28 | /// \brief View of a bimap that is signature compatible with std::unordered_set. 29 | /** 30 | 31 | This class uses container_adaptor and iterator_adaptor to wrapped a index of the 32 | multi_index bimap core so it can be used as a std::unordered_set. 33 | 34 | See also const_unordered_set_view. 35 | **/ 36 | 37 | template< class CoreIndex > 38 | class unordered_set_view 39 | : 40 | public BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR( 41 | unordered_set_adaptor, 42 | CoreIndex, 43 | local_iterator, 44 | const_local_iterator 45 | ), 46 | 47 | public ::boost::bimaps::detail:: 48 | set_view_base< unordered_set_view< CoreIndex >, CoreIndex > 49 | { 50 | BOOST_BIMAP_SET_VIEW_BASE_FRIEND(unordered_set_view,CoreIndex) 51 | 52 | typedef BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR( 53 | unordered_set_adaptor, 54 | CoreIndex, 55 | local_iterator, 56 | const_local_iterator 57 | 58 | ) base_; 59 | 60 | public: 61 | 62 | unordered_set_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) 63 | : base_(c) {} 64 | 65 | unordered_set_view & operator=(const unordered_set_view & v) 66 | { 67 | this->base() = v.base(); 68 | return *this; 69 | } 70 | }; 71 | 72 | 73 | } // namespace views 74 | } // namespace bimaps 75 | } // namespace boost 76 | 77 | #endif // BOOST_BIMAP_VIEWS_UNORDERED_SET_VIEW_HPP 78 | 79 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Automatic redirection failed, please go to the 7 | Boost.Bimap documentation. 8 |

Copyright Matias Capeletto 2006-2007

9 |

Distributed under the Boost Software License, Version 1.0. (See accompanying file 10 | LICENSE_1_0.txt or copy at 11 | www.boost.org/LICENSE_1_0.txt). 12 |

13 | 14 | 15 | -------------------------------------------------------------------------------- /meta/libraries.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "bimap", 3 | "name": "Bimap", 4 | "authors": [ 5 | "Matias Capeletto" 6 | ], 7 | "description": "Bidirectional maps library for C++. With Boost.Bimap you can create associative containers in which both types can be used as key.", 8 | "category": [ 9 | "Containers", 10 | "Data" 11 | ], 12 | "maintainers": [ 13 | "Matias Capeletto " 14 | ], 15 | "cxxstd": "03" 16 | } 17 | -------------------------------------------------------------------------------- /test/compile_fail/test_bimap_info_1.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | // Boost.Bimap 21 | #include 22 | #include 23 | 24 | 25 | void test_bimap_info_1() 26 | { 27 | using namespace boost::bimaps; 28 | 29 | typedef bimap< int, list_of, with_info > bm_type; 30 | bm_type bm; 31 | bm.insert( bm_type::value_type(1,1) ); 32 | 33 | // fail test 34 | { 35 | const bm_type & cbm = bm; 36 | cbm.begin()->info = 10; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/compile_fail/test_bimap_info_2.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | // Boost.Bimap 21 | #include 22 | #include 23 | 24 | 25 | void test_bimap_info_2() 26 | { 27 | using namespace boost::bimaps; 28 | 29 | typedef bimap< int, list_of > bm_type; 30 | bm_type bm; 31 | bm.insert( bm_type::value_type(1,1) ); 32 | 33 | // fail test 34 | { 35 | bm.begin()->info; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/compile_fail/test_bimap_info_3.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | // Boost.Bimap 21 | #include 22 | #include 23 | 24 | 25 | void test_bimap_info_3() 26 | { 27 | using namespace boost::bimaps; 28 | 29 | typedef bimap< int, list_of > bm_type; 30 | bm_type bm; 31 | bm.insert( bm_type::value_type(1,1) ); 32 | 33 | // fail test 34 | { 35 | bm.left.info_at(1); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/compile_fail/test_bimap_mutable_1.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | // Boost.Bimap 21 | #include 22 | #include 23 | 24 | 25 | void test_bimap_mutable_1() 26 | { 27 | using namespace boost::bimaps; 28 | 29 | typedef bimap< int, list_of > bm_type; 30 | bm_type bm; 31 | bm.insert( bm_type::value_type(1,1) ); 32 | 33 | // fail test 34 | { 35 | const bm_type & cbm = bm; 36 | cbm.begin()->right = 10; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/compile_fail/test_bimap_mutable_2.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | // Boost.Bimap 21 | #include 22 | #include 23 | 24 | 25 | void test_bimap_mutable_2() 26 | { 27 | using namespace boost::bimaps; 28 | 29 | typedef bimap< int, list_of > bm_type; 30 | bm_type bm; 31 | bm.insert( bm_type::value_type(1,1) ); 32 | 33 | // fail test 34 | { 35 | const bm_type & cbm = bm; 36 | cbm.left.find(1)->second = 10; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/compile_fail/test_bimap_mutable_3.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | // Boost.Bimap 21 | #include 22 | #include 23 | 24 | 25 | void test_bimap_mutable_3() 26 | { 27 | using namespace boost::bimaps; 28 | 29 | typedef bimap< int, list_of > bm_type; 30 | bm_type bm; 31 | bm.insert( bm_type::value_type(1,1) ); 32 | 33 | // fail test 34 | { 35 | bm.right.begin()->second = 10; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/strong_type.hpp: -------------------------------------------------------------------------------- 1 | // Boost.Bimap 2 | // 3 | // Copyright (c) 2024 Joaquin M Lopez Munoz 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 | #ifndef LIBS_BIMAP_TEST_STRONG_TYPE_HPP 10 | #define LIBS_BIMAP_TEST_STRONG_TYPE_HPP 11 | 12 | #if defined(_MSC_VER) 13 | #pragma once 14 | #endif 15 | 16 | #include 17 | 18 | // std 19 | #include 20 | #include 21 | 22 | template< class T > 23 | struct strong 24 | { 25 | template< class Q > 26 | strong(const Q& x_):x(x_){} 27 | 28 | T x; 29 | }; 30 | 31 | template< class T > 32 | bool operator<(const strong& x,const strong& y) 33 | { 34 | return x.x 38 | bool operator==(const strong& x,const strong& y) 39 | { 40 | return x.x==y.x; 41 | } 42 | 43 | template< class T > 44 | std::size_t hash_value(const strong& x) 45 | { 46 | return boost::hash()(x.x); 47 | } 48 | 49 | template< class T > 50 | struct semistrong: strong 51 | { 52 | using strong::strong; 53 | 54 | // semistrong is formally convertible to T but throws when 55 | // conversion actually called 56 | 57 | operator const T&() const 58 | { 59 | throw std::runtime_error("semistrong -> T conversion called"); 60 | } 61 | }; 62 | 63 | #endif // LIBS_BIMAP_TEST_STRONG_TYPE_HPP 64 | -------------------------------------------------------------------------------- /test/test_bimap_assign.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | // std 21 | #include 22 | #include 23 | #include 24 | 25 | // Boost 26 | #include 27 | #include 28 | 29 | // Boost.Bimap 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | namespace ba = boost::assign; 36 | 37 | 38 | void test_bimap_assign() 39 | { 40 | using namespace boost::bimaps; 41 | 42 | // test 43 | { 44 | typedef bimap< list_of, double > bm_type; 45 | bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3); 46 | ba::push_back( bm )(4,0.4)(5,0.5); 47 | ba::insert( bm.right )(0.5,5)(0.6,6); 48 | ba::push_back( bm.left )(6,0.6)(7,0.7); 49 | } 50 | 51 | // test 52 | { 53 | typedef bimap< unordered_multiset_of, vector_of, 54 | list_of_relation > bm_type; 55 | bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3); 56 | ba::push_front( bm )(4,0.4)(5,0.5); 57 | ba::push_back( bm.right )(0.6,6)(0.7,7); 58 | ba::insert( bm.left )(8,0.8)(9,0.9); 59 | } 60 | 61 | // test 62 | { 63 | typedef bimap< int, vector_of, right_based > bm_type; 64 | bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3); 65 | ba::push_back( bm )(4,0.4)(5,0.5); 66 | ba::push_back( bm.right )(0.6,6)(0.7,7); 67 | ba::insert( bm.left )(8,0.8)(9,0.9); 68 | } 69 | 70 | // test 71 | { 72 | typedef bimap< int, vector_of, set_of_relation<> > bm_type; 73 | bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3); 74 | ba::insert( bm )(4,0.4)(5,0.5); 75 | ba::push_back( bm.right )(0.6,6)(0.7,7); 76 | ba::insert( bm.left )(8,0.8)(9,0.9); 77 | } 78 | } 79 | 80 | 81 | int main() 82 | { 83 | test_bimap_assign(); 84 | return 0; 85 | } 86 | 87 | -------------------------------------------------------------------------------- /test/test_bimap_convenience_header.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | void test_bimap_convenience_header() 25 | { 26 | typedef boost::bimap< int, double > bm_type; 27 | bm_type bm; 28 | bm.insert( bm_type::value_type(1,0.1) ); 29 | BOOST_TEST( bm.right.at(0.1) == 1 ); 30 | } 31 | 32 | int main() 33 | { 34 | test_bimap_convenience_header(); 35 | return boost::report_errors(); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /test/test_bimap_extra.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | // Boost.Bimap 24 | #include 25 | #include 26 | #include 27 | 28 | // Support metafunctions 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | using namespace boost::bimaps; 37 | using namespace boost::bimaps::support; 38 | using namespace boost::bimaps::relation::support ; 39 | 40 | typedef bimap > bm_type; 41 | 42 | namespace support_metafunctions_test { 43 | 44 | typedef boost::is_same 45 | < 46 | data_type_by< member_at::left , bm_type >::type, 47 | key_type_by < member_at::right, bm_type >::type 48 | 49 | >::type test_metafunction_1; 50 | BOOST_STATIC_ASSERT(test_metafunction_1::value); 51 | 52 | typedef boost::is_same 53 | < 54 | data_type_by< member_at::right, bm_type >::type, 55 | key_type_by < member_at::left , bm_type >::type 56 | 57 | >::type test_metafunction_2; 58 | BOOST_STATIC_ASSERT(test_metafunction_2::value); 59 | 60 | typedef boost::is_same 61 | < 62 | map_type_by < member_at::left , bm_type >::type::value_type, 63 | value_type_by< member_at::left , bm_type >::type 64 | 65 | >::type test_metafunction_3; 66 | BOOST_STATIC_ASSERT(test_metafunction_3::value); 67 | 68 | typedef boost::is_same 69 | < 70 | pair_type_by< member_at::left, bm_type::relation>::type, 71 | value_type_by< member_at::left , bm_type >::type 72 | 73 | >::type test_metafunction_4; 74 | BOOST_STATIC_ASSERT(test_metafunction_4::value); 75 | 76 | } // namespace support_metafunctions_test 77 | 78 | void test_bimap_extra() 79 | { 80 | // extra tests 81 | // --------------------------------------------------------------- 82 | // This section test small things... when a group of this checks 83 | // can be related it is moved to a separate unit test file. 84 | 85 | 86 | 87 | } 88 | 89 | 90 | int main() 91 | { 92 | test_bimap_extra(); 93 | return 0; 94 | } 95 | 96 | -------------------------------------------------------------------------------- /test/test_bimap_lambda.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | #include 21 | 22 | // Boost.Bimap 23 | #include 24 | #include 25 | 26 | void test_bimap_lambda() 27 | { 28 | using namespace boost::bimaps; 29 | 30 | typedef bimap bm; 31 | 32 | bm b; 33 | b.insert( bm::value_type(1,0.1) ); 34 | 35 | BOOST_TEST( b.size() == 1 ); 36 | BOOST_TEST( b.left.modify_key ( b.left.begin(), _key = 2 ) ); 37 | BOOST_TEST( b.left.modify_data( b.left.begin(), _data = 0.2 ) ); 38 | BOOST_TEST( b.left.range( _key >= 1, _key < 3 ).first == b.left.begin() ); 39 | } 40 | 41 | int main() 42 | { 43 | test_bimap_lambda(); 44 | return boost::report_errors(); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /test/test_bimap_list_of.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | int main() 25 | { 26 | typedef boost::bimaps::list_of set_type; 27 | typedef boost::bimaps::list_of_relation set_type_of_relation; 28 | boost::ignore_unused(); 29 | boost::ignore_unused(); 30 | 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /test/test_bimap_multiset_of.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | int main() 25 | { 26 | typedef boost::bimaps::multiset_of set_type; 27 | typedef boost::bimaps::multiset_of_relation<> set_type_of_relation; 28 | boost::ignore_unused(); 29 | boost::ignore_unused(); 30 | 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /test/test_bimap_property_map.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | // std 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | // Boost.Bimap 30 | 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | 37 | #include 38 | 39 | 40 | template 41 | void test_readable_property_map( 42 | Map m, 43 | typename boost::property_traits:: key_type const & key, 44 | typename boost::property_traits::value_type const & value 45 | ) 46 | { 47 | // TODO Add STATIC_ASSERT( 48 | // boost::property_traits::category is readable ) 49 | 50 | BOOST_TEST( get(m,key) == value ); 51 | //BOOST_TEST( m[key] == value ); 52 | } 53 | 54 | 55 | void test_bimap_property_map() 56 | { 57 | using namespace boost::bimaps; 58 | 59 | typedef bimap< set_of, unordered_set_of > bm; 60 | 61 | bm b; 62 | b.insert( bm::value_type(1,0.1) ); 63 | b.insert( bm::value_type(2,0.2) ); 64 | b.insert( bm::value_type(3,0.3) ); 65 | 66 | test_readable_property_map(b.left , 1,0.1); 67 | test_readable_property_map(b.right,0.1, 1); 68 | } 69 | 70 | int main() 71 | { 72 | test_bimap_property_map(); 73 | return boost::report_errors(); 74 | } 75 | 76 | -------------------------------------------------------------------------------- /test/test_bimap_serialization.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | // std 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | // Boost 32 | #include 33 | #include 34 | 35 | // Boost.Bimap 36 | #include 37 | 38 | 39 | template< class Bimap, class Archive > 40 | void save_bimap(const Bimap & b, Archive & ar) 41 | { 42 | using namespace boost::bimaps; 43 | 44 | ar << b; 45 | 46 | const typename Bimap::left_const_iterator left_iter = b.left.begin(); 47 | ar << left_iter; 48 | 49 | const typename Bimap::const_iterator iter = ++b.begin(); 50 | ar << iter; 51 | } 52 | 53 | 54 | 55 | 56 | void test_bimap_serialization() 57 | { 58 | using namespace boost::bimaps; 59 | 60 | typedef bimap bm; 61 | 62 | std::set< bm::value_type > data; 63 | data.insert( bm::value_type(1,0.1) ); 64 | data.insert( bm::value_type(2,0.2) ); 65 | data.insert( bm::value_type(3,0.3) ); 66 | data.insert( bm::value_type(4,0.4) ); 67 | 68 | std::ostringstream oss; 69 | 70 | // Save it 71 | { 72 | bm b; 73 | 74 | b.insert(data.begin(),data.end()); 75 | 76 | boost::archive::text_oarchive oa(oss); 77 | 78 | save_bimap(b,oa); 79 | } 80 | 81 | // Reload it 82 | { 83 | bm b; 84 | 85 | std::istringstream iss(oss.str()); 86 | boost::archive::text_iarchive ia(iss); 87 | 88 | ia >> b; 89 | 90 | BOOST_TEST( std::equal( b.begin(), b.end(), data.begin() ) ); 91 | 92 | bm::left_const_iterator left_iter; 93 | 94 | ia >> left_iter; 95 | 96 | BOOST_TEST( left_iter == b.left.begin() ); 97 | 98 | bm::const_iterator iter; 99 | 100 | ia >> iter; 101 | 102 | BOOST_TEST( iter == ++b.begin() ); 103 | } 104 | 105 | } 106 | 107 | 108 | int main() 109 | { 110 | test_bimap_serialization(); 111 | return boost::report_errors(); 112 | } 113 | 114 | -------------------------------------------------------------------------------- /test/test_bimap_set_of.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | int main() 25 | { 26 | typedef boost::bimaps::set_of set_type; 27 | typedef boost::bimaps::set_of_relation<> set_type_of_relation; 28 | boost::ignore_unused(); 29 | boost::ignore_unused(); 30 | 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /test/test_bimap_unconstrained.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | #include 21 | 22 | // Boost.Bimap 23 | #include 24 | #include 25 | 26 | 27 | void test_bimap_unconstrained() 28 | { 29 | using namespace boost::bimaps; 30 | 31 | { 32 | typedef bimap bm; 33 | bm b; 34 | b.left.insert( bm::left_value_type(2,34.4) ); 35 | b.right.insert( bm::right_value_type(2.2,3) ); 36 | } 37 | 38 | { 39 | typedef bimap > bm; 40 | bm b; 41 | b.insert( bm::value_type(2,34.4) ); 42 | BOOST_TEST( b.size() == 1 ); 43 | } 44 | 45 | { 46 | typedef bimap, double > bm; 47 | bm b; 48 | b.right[2.4] = 34; 49 | BOOST_TEST( b.right.size() == 1 ); 50 | } 51 | 52 | { 53 | typedef bimap, double, right_based > bm; 54 | bm b; 55 | b.right[2.4] = 34; 56 | BOOST_TEST( b.right.size() == 1 ); 57 | } 58 | 59 | { 60 | typedef bimap 61 | < 62 | int, 63 | unconstrained_set_of, 64 | unconstrained_set_of_relation 65 | 66 | > bm; 67 | 68 | bm b; 69 | b.left[2] = 34.4; 70 | BOOST_TEST( b.left.size() == 1 ); 71 | } 72 | 73 | { 74 | typedef bimap 75 | < 76 | unconstrained_set_of, 77 | double, 78 | unconstrained_set_of_relation 79 | 80 | > bm; 81 | 82 | bm b; 83 | b.right[2.4] = 34; 84 | BOOST_TEST( b.right.size() == 1 ); 85 | } 86 | 87 | { 88 | typedef bimap 89 | < 90 | unconstrained_set_of, 91 | unconstrained_set_of, 92 | set_of_relation<> 93 | 94 | > bm; 95 | 96 | bm b; 97 | b.insert( bm::value_type(1,2.3) ); 98 | BOOST_TEST( b.size() == 1 ); 99 | } 100 | } 101 | 102 | 103 | int main() 104 | { 105 | test_bimap_unconstrained(); 106 | return boost::report_errors(); 107 | } 108 | 109 | -------------------------------------------------------------------------------- /test/test_bimap_unordered_multiset_of.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | int main() 25 | { 26 | typedef boost::bimaps::unordered_multiset_of set_type; 27 | 28 | typedef boost::bimaps:: 29 | unordered_multiset_of_relation<> set_type_of_relation; 30 | 31 | boost::ignore_unused(); 32 | boost::ignore_unused(); 33 | 34 | return 0; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /test/test_bimap_unordered_set_of.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | int main() 25 | { 26 | typedef boost::bimaps::unordered_set_of set_type; 27 | typedef boost::bimaps::unordered_set_of_relation<> set_type_of_relation; 28 | boost::ignore_unused(); 29 | boost::ignore_unused(); 30 | 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /test/test_bimap_vector_of.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | int main() 25 | { 26 | typedef boost::bimaps::vector_of set_type; 27 | typedef boost::bimaps::vector_of_relation set_type_of_relation; 28 | boost::ignore_unused(); 29 | boost::ignore_unused(); 30 | 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /test/test_mutant.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | #include 21 | 22 | // Boost.MPL 23 | #include 24 | #include 25 | 26 | // Boost.Bimap 27 | #include 28 | 29 | using namespace boost::bimaps::relation::detail; 30 | 31 | // The mutant idiom is standard if only POD types are used. 32 | 33 | typedef double type_a; 34 | typedef int type_b; 35 | 36 | const type_a value_a = 1.4; 37 | const type_b value_b = 3; 38 | 39 | struct Data 40 | { 41 | type_a a; 42 | type_b b; 43 | }; 44 | 45 | struct StdPairView 46 | { 47 | typedef type_a first_type; 48 | typedef type_b second_type; 49 | type_a first; 50 | type_b second; 51 | }; 52 | 53 | struct ReverseStdPairView 54 | { 55 | typedef type_a second_type; 56 | typedef type_b first_type; 57 | type_a second; 58 | type_b first; 59 | }; 60 | 61 | 62 | struct MutantData 63 | { 64 | typedef boost::mpl::list< StdPairView, ReverseStdPairView > mutant_views; 65 | 66 | MutantData(type_a ap, type_b bp) : a(ap), b(bp) {} 67 | type_a a; 68 | type_b b; 69 | }; 70 | 71 | 72 | void test_mutant_basic() 73 | { 74 | 75 | // mutant test 76 | { 77 | MutantData m(value_a,value_b); 78 | 79 | BOOST_TEST( sizeof( MutantData ) == sizeof( StdPairView ) ); 80 | 81 | BOOST_TEST( mutate(m).first == value_a ); 82 | BOOST_TEST( mutate(m).second == value_b ); 83 | BOOST_TEST( mutate(m).first == value_b ); 84 | BOOST_TEST( mutate(m).second == value_a ); 85 | 86 | ReverseStdPairView & rpair = mutate(m); 87 | rpair.first = value_b; 88 | rpair.second = value_a; 89 | 90 | BOOST_TEST( mutate(m).first == value_a ); 91 | BOOST_TEST( mutate(m).second == value_b ); 92 | 93 | BOOST_TEST( &mutate(m).first == &m.a ); 94 | BOOST_TEST( &mutate(m).second == &m.b ); 95 | } 96 | } 97 | 98 | int main() 99 | { 100 | test_mutant_basic(); 101 | return boost::report_errors(); 102 | } 103 | -------------------------------------------------------------------------------- /test/test_structured_pair.cpp: -------------------------------------------------------------------------------- 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 | // VC++ 8.0 warns on usage of certain Standard Library and API functions that 10 | // can be cause buffer overruns or other possible security issues if misused. 11 | // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx 12 | // But the wording of the warning is misleading and unsettling, there are no 13 | // portable alternative functions, and VC++ 8.0's own libraries use the 14 | // functions in question. So turn off the warnings. 15 | #define _CRT_SECURE_NO_DEPRECATE 16 | #define _SCL_SECURE_NO_DEPRECATE 17 | 18 | #include 19 | 20 | #include 21 | 22 | // std 23 | #include 24 | #include 25 | 26 | // Boost.Static_assert 27 | #include 28 | 29 | // Boost.Bimap 30 | #include 31 | 32 | #include 33 | 34 | 35 | BOOST_BIMAP_TEST_STATIC_FUNCTION( static_metadata_test ) 36 | { 37 | using namespace boost::bimaps::relation; 38 | 39 | struct data_a { char data; }; 40 | struct data_b { double data; }; 41 | 42 | typedef structured_pair 43 | < 44 | data_a, 45 | data_b, 46 | normal_layout 47 | 48 | > sp_ab; 49 | 50 | typedef structured_pair 51 | < 52 | data_b, 53 | data_a, 54 | mirror_layout 55 | 56 | > sp_ba; 57 | 58 | BOOST_BIMAP_CHECK_METADATA(sp_ab, first_type , data_a); 59 | BOOST_BIMAP_CHECK_METADATA(sp_ab, second_type, data_b); 60 | 61 | BOOST_BIMAP_CHECK_METADATA(sp_ba, first_type , data_b); 62 | BOOST_BIMAP_CHECK_METADATA(sp_ba, second_type, data_a); 63 | 64 | } 65 | 66 | 67 | void test_basic() 68 | { 69 | 70 | using namespace boost::bimaps::relation; 71 | 72 | // Instantiate two pairs and test the storage alignmentDataData 73 | 74 | typedef structured_pair< short, double, normal_layout > pair_type; 75 | typedef structured_pair< double, short, mirror_layout > mirror_type; 76 | 77 | pair_type pa( 2, 3.1416 ); 78 | mirror_type pb( 3.1416, 2 ); 79 | 80 | BOOST_TEST( pa.first == pb.second ); 81 | BOOST_TEST( pa.second == pb.first ); 82 | 83 | } 84 | 85 | 86 | int main() 87 | { 88 | 89 | BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION( static_are_storage_compatible_test ); 90 | 91 | BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION( static_metadata_test ); 92 | 93 | test_basic(); 94 | 95 | return boost::report_errors(); 96 | } 97 | 98 | --------------------------------------------------------------------------------