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 unordered_multiset_of.hpp
0010 /// \brief Include support for unordered_multiset constrains for the bimap container
0011 
0012 #ifndef BOOST_BIMAP_UNORDERED_MULTISET_OF_HPP
0013 #define BOOST_BIMAP_UNORDERED_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 <cstdlib>
0024 #include <functional>
0025 #include <boost/functional/hash.hpp>
0026 #include <boost/mpl/bool.hpp>
0027 
0028 #include <boost/concept_check.hpp>
0029 
0030 #include <boost/bimap/detail/concept_tags.hpp>
0031 
0032 #include <boost/bimap/tags/support/value_type_of.hpp>
0033 
0034 #include <boost/bimap/detail/generate_index_binder.hpp>
0035 #include <boost/bimap/detail/generate_view_binder.hpp>
0036 #include <boost/bimap/detail/generate_relation_binder.hpp>
0037 
0038 #include <boost/multi_index/hashed_index.hpp>
0039 
0040 #include <boost/bimap/views/unordered_multimap_view.hpp>
0041 #include <boost/bimap/views/unordered_multiset_view.hpp>
0042 
0043 namespace boost {
0044 namespace bimaps {
0045 
0046 
0047 /// \brief Set Type Specification
0048 /**
0049 This struct is used to specify an unordered_multiset specification.
0050 It is not a container, it is just a metaprogramming facility to
0051 express the type of a set. Generally, this specification will
0052 be used in other place to create a container.
0053 It has the same syntax that an tr1::unordered_multiset instantiation,
0054 except that the allocator cannot be specified. The rationale behind
0055 this difference is that the allocator is not part of the
0056 unordered_multiset type specification, rather it is a container
0057 configuration parameter.
0058 The first parameter is the type of the objects in the set, the
0059 second one is a Hash Functor that takes objects of this type, and
0060 the third one is a Functor that compares them for equality.
0061 Bimap binding metafunctions can be used with this class in
0062 the following way:
0063 
0064 \code
0065 using namespace support;
0066 
0067 BOOST_STATIC_ASSERT( is_set_type_of< unordered_multiset_of<Type> >::value )
0068 
0069 BOOST_STATIC_ASSERT
0070 (
0071      is_same
0072      <
0073         compute_index_type
0074         <
0075             unordered_multiset_of<Type,HashFunctor,EqualKey>,
0076             KeyExtractor,
0077             Tag
0078 
0079         >::type
0080         ,
0081         hashed_nonunique< tag<Tag>, KeyExtractor, HashFunctor, EqualKey >
0082 
0083     >::value
0084 )
0085 
0086 typedef bimap
0087 <
0088     unordered_multiset_of<Type>, RightKeyType
0089 
0090 > bimap_with_left_type_as_unordered_multiset;
0091 
0092 BOOST_STATIC_ASSERT
0093 (
0094     is_same
0095     <
0096         compute_map_view_type
0097         <
0098             member_at::left,
0099             bimap_with_left_type_as_unordered_multiset
0100 
0101         >::type,
0102 
0103         unordered_multimap_view
0104         <
0105             member_at::left,
0106             bimap_with_left_type_as_unordered_multiset
0107         >
0108 
0109     >::value
0110 )
0111 
0112 \endcode
0113 
0114 See also unordered_multiset_of_relation.
0115                                                                         **/
0116 
0117 template
0118 <
0119     class KeyType,
0120     class HashFunctor   = hash< BOOST_DEDUCED_TYPENAME 
0121         ::boost::bimaps::tags::support::value_type_of<KeyType>::type >,
0122     class EqualKey      = std::equal_to< BOOST_DEDUCED_TYPENAME 
0123         ::boost::bimaps::tags::support::value_type_of<KeyType>::type >
0124 >
0125 struct unordered_multiset_of : public ::boost::bimaps::detail::set_type_of_tag
0126 {
0127     /// User type, can be tagged
0128     typedef KeyType user_type;
0129 
0130     /// Type of the object that will be stored in the container
0131     typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
0132         value_type_of<user_type>::type value_type;
0133 
0134     /// Hash Functor that takes value_type objects
0135     typedef HashFunctor     hasher;
0136 
0137     /// Functor that compare two value_type objects for equality
0138     typedef EqualKey        key_equal;
0139 
0140     struct lazy_concept_checked
0141     {
0142         BOOST_CLASS_REQUIRE ( value_type,
0143                               boost, AssignableConcept );
0144 
0145         BOOST_CLASS_REQUIRE3( hasher, std::size_t, value_type,
0146                               boost, UnaryFunctionConcept );
0147 
0148         BOOST_CLASS_REQUIRE4( key_equal, bool, value_type, value_type,
0149                               boost, BinaryFunctionConcept );
0150 
0151         typedef unordered_multiset_of type;
0152     };
0153 
0154     BOOST_BIMAP_GENERATE_INDEX_BINDER_2CP(
0155 
0156         // binds to
0157         multi_index::hashed_non_unique,
0158 
0159         // with
0160         hasher,
0161         key_equal
0162     )
0163 
0164     BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
0165 
0166         // binds to
0167         views::unordered_multimap_view
0168     )
0169 
0170     BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
0171 
0172         // binds to
0173         views::unordered_multiset_view
0174     )
0175 
0176     typedef mpl::bool_<false> mutable_key;
0177 };
0178 
0179 
0180 /// \brief Set Of Relation Specification
0181 /**
0182 This struct is similar to unordered_multiset_of but it is bind logically
0183 to a relation. It is used in the bimap instantiation to specify the
0184 desired type of the main view. This struct implements internally
0185 a metafunction named bind_to that manages the quite complicated
0186 task of finding the right type of the set for the relation.
0187 
0188 \code
0189 template<class Relation>
0190 struct bind_to
0191 {
0192     typedef -unspecified- type;
0193 };
0194 \endcode
0195 
0196 See also unordered_multiset_of, is_set_type_of_relation.
0197                                                                 **/
0198 
0199 template
0200 <
0201     class HashFunctor   = hash< _relation >,
0202     class EqualKey      = std::equal_to< _relation >
0203 >
0204 struct unordered_multiset_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
0205 {
0206     /// Hash Functor that takes value_type objects
0207     typedef HashFunctor     hasher;
0208 
0209     /// Functor that compare two value_type objects for equality
0210     typedef EqualKey        key_equal;
0211 
0212 
0213     BOOST_BIMAP_GENERATE_RELATION_BINDER_2CP(
0214 
0215         // binds to
0216         unordered_multiset_of,
0217 
0218         // with
0219         hasher,
0220         key_equal
0221     )
0222 
0223     typedef mpl::bool_<false>  left_mutable_key;
0224     typedef mpl::bool_<false> right_mutable_key;
0225 };
0226 
0227 
0228 } // namespace bimaps
0229 } // namespace boost
0230 
0231 
0232 #endif // BOOST_BIMAP_UNORDERED_MULTISET_OF_HPP
0233