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

PrevUpHomeNext

list_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 list_of.hpp
00010 /// \brief Include support for list constrains for the bimap container
00011 
00012 #ifndef BOOST_BIMAP_LIST_OF_HPP
00013 #define BOOST_BIMAP_LIST_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 <boost/mpl/bool.hpp>
00024 
00025 #include <boost/bimap/detail/concept_tags.hpp>
00026 
00027 #include <boost/bimap/detail/generate_index_binder.hpp>
00028 #include <boost/bimap/detail/generate_view_binder.hpp>
00029 #include <boost/bimap/detail/generate_relation_binder.hpp>
00030 
00031 #include <boost/multi_index/sequenced_index.hpp>
00032 
00033 #include <boost/bimap/views/list_map_view.hpp>
00034 #include <boost/bimap/views/list_set_view.hpp>
00035 
00036 namespace boost {
00037 namespace bimaps {
00038 
00039 
00040 /// \brief Set Type Specification
00041 /**
00042 This struct is used to specify a set 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::list 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 
00052 \code
00053 using namespace support;
00054 
00055 BOOST_STATIC_ASSERT( is_set_type_of< list_of<Type> >::value );
00056 
00057 BOOST_STATIC_ASSERT
00058 (
00059      is_same
00060      <
00061         list_of<Type>::index_bind
00062         <
00063             KeyExtractor,
00064             Tag
00065 
00066         >::type,
00067 
00068         sequenced< tag<Tag>, KeyExtractor >
00069 
00070     >::value
00071 );
00072 
00073 typedef bimap
00074 <
00075     list_of<Type>, RightKeyType
00076 
00077 > bimap_with_left_type_as_list;
00078 
00079 BOOST_STATIC_ASSERT
00080 (
00081     is_same
00082     <
00083         list_of<Type>::map_view_bind
00084         <
00085             member_at::left,
00086             bimap_with_left_type_as_list
00087 
00088         >::type,
00089         list_map_view< member_at::left, bimap_with_left_type_as_list >
00090 
00091     >::value
00092 );
00093 
00094 \endcode
00095 
00096 See also list_of_relation.
00097                                                                         **/
00098 
00099 template< class Type >
00100 struct list_of : public ::boost::bimaps::detail::set_type_of_tag
00101 {
00102     /// Type of the object that will be stored in the list
00103     typedef Type value_type;
00104 
00105     BOOST_BIMAP_GENERATE_INDEX_BINDER_0CP_NO_EXTRACTOR(
00106 
00107         // binds to
00108         multi_index::sequenced
00109     );
00110 
00111     BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
00112 
00113         // binds to
00114         views::list_map_view
00115     );
00116 
00117     BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
00118 
00119         // binds to
00120         views::list_set_view
00121     );
00122 
00123     typedef mpl::bool_<true> mutable_key;
00124 };
00125 
00126 
00127 /// \brief List Of Relation Specification
00128 /**
00129 This struct is similar to list_of but it is bind logically to a
00130 relation. It is used in the bimap instantiation to specify the
00131 desired type of the main view. This struct implements internally
00132 a metafunction named bind_to that manages the quite complicated
00133 task of finding the right type of the set for the relation.
00134 
00135 \code
00136 template<class Relation>
00137 struct bind_to
00138 {
00139     typedef -unspecified- type;
00140 };
00141 \endcode
00142 
00143 See also list_of, is_set_type_of_relation.
00144                                                                 **/
00145 
00146 struct list_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
00147 {
00148     BOOST_BIMAP_GENERATE_RELATION_BINDER_0CP(
00149 
00150         // binds to
00151         list_of
00152     );
00153 
00154     typedef mpl::bool_<true>  left_mutable_key;
00155     typedef mpl::bool_<true> right_mutable_key;
00156 };
00157 
00158 
00159 } // namespace bimaps
00160 } // namespace boost
00161 
00162 
00163 #endif // BOOST_BIMAP_LIST_OF_HPP
00164 
Copyright 2006 Matias Capeletto

PrevUpHomeNext