Boost C++ Libraries Boost.Bimap Home Libraries People FAQ More

PrevUpHomeNext

multiset_of.hpp

Go to the documentation of this file.
00001 // Boost.Bimap
00002 //
00003 // Copyright (c) 2006-2007 Matias Capeletto
00004 //
00005 // Distributed under the Boost Software License, Version 1.0.
00006 // (See accompanying file LICENSE_1_0.txt or copy at
00007 // http://www.boost.org/LICENSE_1_0.txt)
00008 
00009 /// \file multiset_of.hpp
00010 /// \brief Include support for multiset constrains for the bimap container
00011 
00012 #ifndef BOOST_BIMAP_MULTISET_OF_HPP
00013 #define BOOST_BIMAP_MULTISET_OF_HPP
00014 
00015 #if defined(_MSC_VER) && (_MSC_VER>=1200)
00016 #pragma once
00017 #endif
00018 
00019 #include <boost/config.hpp>
00020 
00021 #include <boost/bimap/detail/user_interface_config.hpp>
00022 
00023 #include <functional>
00024 #include <boost/mpl/bool.hpp>
00025 
00026 #include <boost/bimap/detail/concept_tags.hpp>
00027 
00028 #include <boost/bimap/detail/generate_index_binder.hpp>
00029 #include <boost/bimap/detail/generate_view_binder.hpp>
00030 #include <boost/bimap/detail/generate_relation_binder.hpp>
00031 
00032 #include <boost/multi_index/ordered_index.hpp>
00033 
00034 #include <boost/bimap/views/multimap_view.hpp>
00035 #include <boost/bimap/views/multiset_view.hpp>
00036 
00037 namespace boost {
00038 namespace bimaps {
00039 
00040 /// \brief Set Type Specification
00041 /**
00042 This struct is used to specify a multiset specification.
00043 It is not a container, it is just a metaprogramming facility to
00044 express the type of a set. Generally, this specification will
00045 be used in other place to create a container.
00046 It has the same syntax that an std::set instantiation, except
00047 that the allocator cannot be specified. The rationale behind
00048 this difference is that the allocator is not part of the set
00049 type specification, rather it is a container configuration
00050 parameter.
00051 The first parameter is the type of the objects in the multiset,
00052 and the second one is a Functor that compares them.
00053 Bimap binding metafunctions can be used with this class in
00054 the following way:
00055 
00056 \code
00057 using namespace support;
00058 
00059 BOOST_STATIC_ASSERT( is_set_type_of< multiset_of<Type> >::value );
00060 
00061 BOOST_STATIC_ASSERT
00062 (
00063      is_same
00064      <
00065         compute_index_type
00066         <
00067             multiset_of<Type,KeyCompare>,
00068             KeyExtractor,
00069             Tag
00070 
00071         >::type
00072         ,
00073         ordered_nonunique< tag<Tag>, KeyExtractor, KeyCompare >
00074 
00075     >::value
00076 );
00077 
00078 typedef bimap
00079 <
00080     multiset_of<Type>, RightKeyType
00081 
00082 > bimap_with_left_type_as_multiset;
00083 
00084 BOOST_STATIC_ASSERT
00085 (
00086     is_same
00087     <
00088         compute_map_view_type
00089         <
00090             member_at::left,
00091             bimap_with_left_type_as_multiset
00092 
00093         >::type,
00094         multimap_view< member_at::left, bimap_with_left_type_as_multiset >
00095 
00096     >::value
00097 );
00098 
00099 \endcode
00100 
00101 See also multiset_of_relation.
00102                                                                         **/
00103 
00104 template
00105 <
00106     class KeyType,
00107     class KeyCompare = std::less< KeyType >
00108 >
00109 struct multiset_of : public ::boost::bimaps::detail::set_type_of_tag
00110 {
00111      /// Type of the object that will be stored in the set
00112     typedef KeyType value_type;
00113 
00114     /// Functor that compare two keys
00115     typedef KeyCompare key_compare;
00116 
00117 
00118     BOOST_BIMAP_GENERATE_INDEX_BINDER_1CP(
00119 
00120         // binds to
00121         multi_index::ordered_non_unique,
00122 
00123         // with
00124         key_compare
00125     );
00126 
00127     BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
00128 
00129         // binds to
00130         views::multimap_view
00131     );
00132 
00133     BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
00134 
00135         // binds to
00136         views::multiset_view
00137     );
00138 
00139     typedef mpl::bool_<false> mutable_key;
00140 };
00141 
00142 
00143 /// \brief Set Of Relation Specification
00144 /**
00145 This struct is similar to multiset_of but it is bind logically to a
00146 relation. It is used in the bimap instantiation to specify the
00147 desired type of the main view. This struct implements internally
00148 a metafunction named bind_to that manages the quite complicated
00149 task of finding the right type of the set for the relation.
00150 
00151 \code
00152 template<class Relation>
00153 struct bind_to
00154 {
00155     typedef -unspecified- type;
00156 };
00157 \endcode
00158 
00159 See also multiset_of, is_set_type_of_relation.
00160                                                                 **/
00161 
00162 template< class KeyCompare = std::less< _relation > >
00163 struct multiset_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
00164 {
00165     /// Functor that compare two keys
00166     typedef KeyCompare key_compare;
00167 
00168 
00169     BOOST_BIMAP_GENERATE_RELATION_BINDER_1CP(
00170 
00171         // binds to
00172         multiset_of,
00173 
00174         // with
00175         key_compare
00176     );
00177 
00178     typedef mpl::bool_<false>  left_mutable_key;
00179     typedef mpl::bool_<false> right_mutable_key;
00180 };
00181 
00182 } // namespace bimaps
00183 } // namespace boost
00184 
00185 
00186 #endif // BOOST_BIMAP_MULTISET_OF_HPP
Copyright 2006 Matias Capeletto

PrevUpHomeNext