Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:34:18

0001 // Boost.Bimap
0002 //
0003 // Copyright (c) 2006-2007 Matias Capeletto
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // (See accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 /// \file multiset_of.hpp
0010 /// \brief Include support for multiset constrains for the bimap container
0011 
0012 #ifndef BOOST_BIMAP_MULTISET_OF_HPP
0013 #define BOOST_BIMAP_MULTISET_OF_HPP
0014 
0015 #if defined(_MSC_VER)
0016 #pragma once
0017 #endif
0018 
0019 #include <boost/config.hpp>
0020 
0021 #include <boost/bimap/detail/user_interface_config.hpp>
0022 
0023 #include <functional>
0024 #include <boost/mpl/bool.hpp>
0025 
0026 #include <boost/concept_check.hpp>
0027 
0028 #include <boost/bimap/detail/concept_tags.hpp>
0029 
0030 #include <boost/bimap/tags/support/value_type_of.hpp>
0031 
0032 #include <boost/bimap/detail/generate_index_binder.hpp>
0033 #include <boost/bimap/detail/generate_view_binder.hpp>
0034 #include <boost/bimap/detail/generate_relation_binder.hpp>
0035 
0036 #include <boost/multi_index/ordered_index.hpp>
0037 
0038 #include <boost/bimap/views/multimap_view.hpp>
0039 #include <boost/bimap/views/multiset_view.hpp>
0040 
0041 namespace boost {
0042 namespace bimaps {
0043 
0044 /// \brief Set Type Specification
0045 /**
0046 This struct is used to specify a multiset specification.
0047 It is not a container, it is just a metaprogramming facility to
0048 express the type of a set. Generally, this specification will
0049 be used in other place to create a container.
0050 It has the same syntax that an std::set instantiation, except
0051 that the allocator cannot be specified. The rationale behind
0052 this difference is that the allocator is not part of the set
0053 type specification, rather it is a container configuration
0054 parameter.
0055 The first parameter is the type of the objects in the multiset,
0056 and the second one is a Functor that compares them.
0057 Bimap binding metafunctions can be used with this class in
0058 the following way:
0059 
0060 \code
0061 using namespace support;
0062 
0063 BOOST_STATIC_ASSERT( is_set_type_of< multiset_of<Type> >::value )
0064 
0065 BOOST_STATIC_ASSERT
0066 (
0067      is_same
0068      <
0069         compute_index_type
0070         <
0071             multiset_of<Type,KeyCompare>,
0072             KeyExtractor,
0073             Tag
0074 
0075         >::type
0076         ,
0077         ordered_nonunique< tag<Tag>, KeyExtractor, KeyCompare >
0078 
0079     >::value
0080 )
0081 
0082 typedef bimap
0083 <
0084     multiset_of<Type>, RightKeyType
0085 
0086 > bimap_with_left_type_as_multiset;
0087 
0088 BOOST_STATIC_ASSERT
0089 (
0090     is_same
0091     <
0092         compute_map_view_type
0093         <
0094             member_at::left,
0095             bimap_with_left_type_as_multiset
0096 
0097         >::type,
0098         multimap_view< member_at::left, bimap_with_left_type_as_multiset >
0099 
0100     >::value
0101 )
0102 
0103 \endcode
0104 
0105 See also multiset_of_relation.
0106                                                                         **/
0107 
0108 template
0109 <
0110     class KeyType,
0111     class KeyCompare = std::less< BOOST_DEDUCED_TYPENAME
0112         ::boost::bimaps::tags::support::value_type_of<KeyType>::type >
0113 >
0114 struct multiset_of : public ::boost::bimaps::detail::set_type_of_tag
0115 {
0116     /// User type, can be tagged
0117     typedef KeyType user_type;
0118 
0119     /// Type of the object that will be stored in the multiset
0120     typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
0121         value_type_of<user_type>::type value_type;
0122 
0123     /// Functor that compare two keys
0124     typedef KeyCompare key_compare;
0125 
0126     struct lazy_concept_checked
0127     {
0128         BOOST_CLASS_REQUIRE ( value_type,
0129                               boost, AssignableConcept );
0130 
0131         BOOST_CLASS_REQUIRE4( key_compare, bool, value_type, value_type,
0132                               boost, BinaryFunctionConcept );
0133 
0134         typedef multiset_of type;
0135     };
0136 
0137     BOOST_BIMAP_GENERATE_INDEX_BINDER_1CP(
0138 
0139         // binds to
0140         multi_index::ordered_non_unique,
0141 
0142         // with
0143         key_compare
0144     )
0145 
0146     BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
0147 
0148         // binds to
0149         views::multimap_view
0150     )
0151 
0152     BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
0153 
0154         // binds to
0155         views::multiset_view
0156     )
0157 
0158     typedef mpl::bool_<false> mutable_key;
0159 };
0160 
0161 
0162 /// \brief Set Of Relation Specification
0163 /**
0164 This struct is similar to multiset_of but it is bind logically to a
0165 relation. It is used in the bimap instantiation to specify the
0166 desired type of the main view. This struct implements internally
0167 a metafunction named bind_to that manages the quite complicated
0168 task of finding the right type of the set for the relation.
0169 
0170 \code
0171 template<class Relation>
0172 struct bind_to
0173 {
0174     typedef -unspecified- type;
0175 };
0176 \endcode
0177 
0178 See also multiset_of, is_set_type_of_relation.
0179                                                                 **/
0180 
0181 template< class KeyCompare = std::less< _relation > >
0182 struct multiset_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
0183 {
0184     /// Functor that compare two keys
0185     typedef KeyCompare key_compare;
0186 
0187 
0188     BOOST_BIMAP_GENERATE_RELATION_BINDER_1CP(
0189 
0190         // binds to
0191         multiset_of,
0192 
0193         // with
0194         key_compare
0195     )
0196 
0197     typedef mpl::bool_<false>  left_mutable_key;
0198     typedef mpl::bool_<false> right_mutable_key;
0199 };
0200 
0201 } // namespace bimaps
0202 } // namespace boost
0203 
0204 
0205 #endif // BOOST_BIMAP_MULTISET_OF_HPP