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

PrevUpHomeNext

vector_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 vector_of.hpp
00010 /// \brief Include support for vector constrains for the bimap container
00011 
00012 #ifndef BOOST_BIMAP_VECTOR_OF_HPP
00013 #define BOOST_BIMAP_VECTOR_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/random_access_index.hpp>
00032 
00033 #include <boost/bimap/views/vector_map_view.hpp>
00034 #include <boost/bimap/views/vector_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::vector 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 set, and
00052 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< vector_of<Type> >::value );
00060 
00061 BOOST_STATIC_ASSERT
00062 (
00063      is_same
00064      <
00065         vector_of<Type>::index_bind
00066         <
00067             KeyExtractor,
00068             Tag
00069 
00070         >::type,
00071 
00072         random_access< tag<Tag>, KeyExtractor >
00073 
00074     >::value
00075 );
00076 
00077 typedef bimap
00078 <
00079     vector_of<Type>, RightKeyType
00080 
00081 > bimap_with_left_type_as_vector;
00082 
00083 BOOST_STATIC_ASSERT
00084 (
00085     is_same
00086     <
00087         vector_of<Type>::map_view_bind
00088         <
00089             member_at::left,
00090             bimap_with_left_type_as_vector
00091 
00092         >::type,
00093 
00094         vector_map_view< member_at::left, bimap_with_left_type_as_vector >
00095 
00096     >::value
00097 );
00098 
00099 \endcode
00100 
00101 See also vector_of_relation.
00102                                                                         **/
00103 
00104 template< class Type >
00105 struct vector_of : public ::boost::bimaps::detail::set_type_of_tag
00106 {
00107     /// Type of the object that will be stored in the set
00108     typedef Type value_type;
00109 
00110     BOOST_BIMAP_GENERATE_INDEX_BINDER_0CP_NO_EXTRACTOR(
00111 
00112         // binds to
00113         multi_index::random_access
00114     );
00115 
00116     BOOST_BIMAP_GENERATE_MAP_VIEW_BINDER(
00117 
00118         // binds to
00119         views::vector_map_view
00120     );
00121 
00122     BOOST_BIMAP_GENERATE_SET_VIEW_BINDER(
00123 
00124         // binds to
00125         views::vector_set_view
00126     );
00127 
00128     typedef mpl::bool_<true> mutable_key;
00129 };
00130 
00131 
00132 /// \brief Set Of Relation Specification
00133 /**
00134 This struct is similar to vector_of but it is bind logically to a
00135 relation. It is used in the bimap instantiation to specify the
00136 desired type of the main view. This struct implements internally
00137 a metafunction named bind_to that manages the quite complicated
00138 task of finding the right type of the set for the relation.
00139 
00140 \code
00141 template<class Relation>
00142 struct bind_to
00143 {
00144     typedef -unspecified- type;
00145 };
00146 \endcode
00147 
00148 See also vector_of, is_set_type_of_relation.
00149                                                                 **/
00150 
00151 struct vector_of_relation : public ::boost::bimaps::detail::set_type_of_relation_tag
00152 {
00153     BOOST_BIMAP_GENERATE_RELATION_BINDER_0CP(
00154 
00155         // binds to
00156         vector_of
00157     );
00158 
00159     typedef mpl::bool_<true>  left_mutable_key;
00160     typedef mpl::bool_<true> right_mutable_key;
00161 };
00162 
00163 
00164 } // namespace bimaps
00165 } // namespace boost
00166 
00167 
00168 #endif // BOOST_BIMAP_VECTOR_OF_HPP
00169 
Copyright 2006 Matias Capeletto

PrevUpHomeNext