index_base.hpp
Go to the documentation of this file.
1 /* Copyright 2003-2014 Joaquin M Lopez Munoz.
2  * Distributed under the Boost Software License, Version 1.0.
3  * (See accompanying file LICENSE_1_0.txt or copy at
4  * http://www.boost.org/LICENSE_1_0.txt)
5  *
6  * See http://www.boost.org/libs/multi_index for library home page.
7  */
8 
9 #ifndef BOOST_MULTI_INDEX_DETAIL_INDEX_BASE_HPP
10 #define BOOST_MULTI_INDEX_DETAIL_INDEX_BASE_HPP
11 
12 #if defined(_MSC_VER)
13 #pragma once
14 #endif
15 
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
20 #include <boost/move/core.hpp>
21 #include <boost/move/utility.hpp>
22 #include <boost/mpl/vector.hpp>
28 #include <boost/tuple/tuple.hpp>
29 #include <utility>
30 
31 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
34 #endif
35 
36 namespace boost{
37 
38 namespace multi_index{
39 
40 namespace detail{
41 
42 /* The role of this class is threefold:
43  * - tops the linear hierarchy of indices.
44  * - terminates some cascading backbone function calls (insert_, etc.),
45  * - grants access to the backbone functions of the final
46  * multi_index_container class (for access restriction reasons, these
47  * cannot be called directly from the index classes.)
48  */
49 
50 struct lvalue_tag{};
51 struct rvalue_tag{};
52 struct emplaced_tag{};
53 
54 template<typename Value,typename IndexSpecifierList,typename Allocator>
56 {
57 protected:
59  typedef typename multi_index_node_type<
60  Value,IndexSpecifierList,Allocator>::type final_node_type;
61  typedef multi_index_container<
62  Value,IndexSpecifierList,Allocator> final_type;
64  typedef typename
66  Allocator,
67  typename Allocator::value_type
72  typedef copy_map<
75 
76 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
77  typedef index_saver<
78  node_type,
80  typedef index_loader<
81  node_type,
84 #endif
85 
86 private:
87  typedef Value value_type;
88 
89 protected:
90  explicit index_base(const ctor_args_list&,const Allocator&){}
91 
95  {}
96 
97  void copy_(
99  {}
100 
102  {
103  x=final().allocate_node();
104  BOOST_TRY{
106  }
107  BOOST_CATCH(...){
108  final().deallocate_node(x);
110  }
112  return x;
113  }
114 
116  {
117  x=final().allocate_node();
118  BOOST_TRY{
119  /* This shoud have used a modified, T&&-compatible version of
120  * boost::detail::allocator::construct, but
121  * <boost/detail/allocator_utilities.hpp> is too old and venerable to
122  * mess with; besides, it is a general internal utility and the imperfect
123  * perfect forwarding emulation of Boost.Move might break other libs.
124  */
125 
126  new (&x->value()) value_type(boost::move(const_cast<value_type&>(v)));
127  }
128  BOOST_CATCH(...){
129  final().deallocate_node(x);
131  }
133  return x;
134  }
135 
137  {
138  return x;
139  }
140 
143  {
144  return insert_(v,x,lvalue_tag());
145  }
146 
149  {
150  return insert_(v,x,rvalue_tag());
151  }
152 
155  {
156  return x;
157  }
158 
159  void erase_(node_type* x)
160  {
162  }
163 
165  {
167  }
168 
169  void clear_(){}
170 
172 
174 
176  {
177  x->value()=v;
178  return true;
179  }
180 
182  {
183  x->value()=boost::move(const_cast<value_type&>(v));
184  return true;
185  }
186 
187  bool modify_(node_type*){return true;}
188 
189  bool modify_rollback_(node_type*){return true;}
190 
191 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
192  /* serialization */
193 
194  template<typename Archive>
195  void save_(Archive&,const unsigned int,const index_saver_type&)const{}
196 
197  template<typename Archive>
198  void load_(Archive&,const unsigned int,const index_loader_type&){}
199 #endif
200 
201 #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
202  /* invariant stuff */
203 
204  bool invariant_()const{return true;}
205 #endif
206 
207  /* access to backbone memfuns of Final class */
208 
209  final_type& final(){return *static_cast<final_type*>(this);}
210  const final_type& final()const{return *static_cast<const final_type*>(this);}
211 
212  final_node_type* final_header()const{return final().header();}
213 
214  bool final_empty_()const{return final().empty_();}
215  std::size_t final_size_()const{return final().size_();}
216  std::size_t final_max_size_()const{return final().max_size_();}
217 
218  std::pair<final_node_type*,bool> final_insert_(const value_type& x)
219  {return final().insert_(x);}
220  std::pair<final_node_type*,bool> final_insert_rv_(const value_type& x)
221  {return final().insert_rv_(x);}
222  template<typename T>
223  std::pair<final_node_type*,bool> final_insert_ref_(const T& t)
224  {return final().insert_ref_(t);}
225  template<typename T>
226  std::pair<final_node_type*,bool> final_insert_ref_(T& t)
227  {return final().insert_ref_(t);}
228 
229  template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK>
230  std::pair<final_node_type*,bool> final_emplace_(
232  {
233  return final().emplace_(BOOST_MULTI_INDEX_FORWARD_PARAM_PACK);
234  }
235 
236  std::pair<final_node_type*,bool> final_insert_(
237  const value_type& x,final_node_type* position)
238  {return final().insert_(x,position);}
239  std::pair<final_node_type*,bool> final_insert_rv_(
240  const value_type& x,final_node_type* position)
241  {return final().insert_rv_(x,position);}
242  template<typename T>
243  std::pair<final_node_type*,bool> final_insert_ref_(
244  const T& t,final_node_type* position)
245  {return final().insert_ref_(t,position);}
246  template<typename T>
247  std::pair<final_node_type*,bool> final_insert_ref_(
248  T& t,final_node_type* position)
249  {return final().insert_ref_(t,position);}
250 
251  template<BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK>
252  std::pair<final_node_type*,bool> final_emplace_hint_(
254  {
255  return final().emplace_hint_(
257  }
258 
259  void final_erase_(final_node_type* x){final().erase_(x);}
260 
262  void final_delete_all_nodes_(){final().delete_all_nodes_();}
263  void final_clear_(){final().clear_();}
264 
265  void final_swap_(final_type& x){final().swap_(x);}
266 
268  const value_type& k,final_node_type* x)
269  {return final().replace_(k,x);}
271  const value_type& k,final_node_type* x)
272  {return final().replace_rv_(k,x);}
273 
274  template<typename Modifier>
275  bool final_modify_(Modifier& mod,final_node_type* x)
276  {return final().modify_(mod,x);}
277 
278  template<typename Modifier,typename Rollback>
279  bool final_modify_(Modifier& mod,Rollback& back,final_node_type* x)
280  {return final().modify_(mod,back,x);}
281 
282 #if defined(BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING)
283  void final_check_invariant_()const{final().check_invariant_();}
284 #endif
285 };
286 
287 } /* namespace multi_index::detail */
288 
289 } /* namespace multi_index */
290 
291 } /* namespace boost */
292 
293 #endif
index_saver.hpp
boost::multi_index::detail::multi_index_node_type
Definition: node_type.hpp:49
boost::multi_index::detail::index_base::final_allocator_type
boost::detail::allocator::rebind_to< Allocator, typename Allocator::value_type >::type final_allocator_type
Definition: index_base.hpp:68
boost::multi_index::detail::do_not_copy_elements_tag
Definition: do_not_copy_elements_tag.hpp:26
boost::multi_index::detail::index_base::final_node_type
multi_index_node_type< Value, IndexSpecifierList, Allocator >::type final_node_type
Definition: index_base.hpp:60
boost::multi_index::detail::index_base::index_base
index_base(const ctor_args_list &, const Allocator &)
Definition: index_base.hpp:90
no_exceptions_support.hpp
vector.hpp
boost::multi_index::detail::index_base::modify_rollback_
bool modify_rollback_(node_type *)
Definition: index_base.hpp:189
T
T
Definition: mem_fn_cc.hpp:25
boost::multi_index::detail::index_base::final_insert_ref_
std::pair< final_node_type *, bool > final_insert_ref_(T &t, final_node_type *position)
Definition: index_base.hpp:247
config.hpp
boost::multi_index::detail::index_base::final_emplace_
std::pair< final_node_type *, bool > final_emplace_(BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK)
Definition: index_base.hpp:230
boost::multi_index::detail::index_loader
Definition: index_loader.hpp:39
boost::multi_index::detail::index_base::final_modify_
bool final_modify_(Modifier &mod, Rollback &back, final_node_type *x)
Definition: index_base.hpp:279
boost::multi_index::detail::index_base::final_max_size_
std::size_t final_max_size_() const
Definition: index_base.hpp:216
tuple.hpp
boost::multi_index::detail::index_base::final_insert_ref_
std::pair< final_node_type *, bool > final_insert_ref_(const T &t)
Definition: index_base.hpp:223
boost::multi_index::detail::index_base::final_header
final_node_type * final_header() const
Definition: index_base.hpp:212
boost::multi_index::detail::index_base::index_base
index_base(const index_base< Value, IndexSpecifierList, Allocator > &, do_not_copy_elements_tag)
Definition: index_base.hpp:92
multi_index_container_fwd.hpp
boost::type
Definition: type.hpp:14
boost::multi_index::detail::index_base::insert_
final_node_type * insert_(const value_type &v, node_type *, final_node_type *&x, rvalue_tag)
Definition: index_base.hpp:147
boost::multi_index::detail::index_base::index_type_list
mpl::vector0 index_type_list
Definition: index_base.hpp:69
boost::multi_index::detail::index_base::final_size_
std::size_t final_size_() const
Definition: index_base.hpp:215
boost::multi_index::detail::index_base::copy_
void copy_(const index_base< Value, IndexSpecifierList, Allocator > &, const copy_map_type &)
Definition: index_base.hpp:97
boost
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
boost::multi_index::detail::lvalue_tag
Definition: index_base.hpp:50
boost::multi_index::detail::index_base::ctor_args_list
tuples::null_type ctor_args_list
Definition: index_base.hpp:63
boost::multi_index::detail::index_base::final_insert_rv_
std::pair< final_node_type *, bool > final_insert_rv_(const value_type &x)
Definition: index_base.hpp:220
boost::multi_index::detail::index_saver
Definition: index_saver.hpp:38
boost::multi_index::detail::index_base::final_insert_
std::pair< final_node_type *, bool > final_insert_(const value_type &x)
Definition: index_base.hpp:218
boost::multi_index::detail::index_base::insert_
final_node_type * insert_(const value_type &, node_type *, final_node_type *&x, emplaced_tag)
Definition: index_base.hpp:153
boost::multi_index::detail::index_base
Definition: index_base.hpp:55
boost::multi_index::detail::index_base::modify_
bool modify_(node_type *)
Definition: index_base.hpp:187
boost::multi_index::detail::index_base::final_empty_
bool final_empty_() const
Definition: index_base.hpp:214
boost::multi_index::detail::index_base::final_clear_
void final_clear_()
Definition: index_base.hpp:263
boost::detail::allocator::rebind_to
Definition: allocator_utilities.hpp:139
copy_map.hpp
boost::multi_index::detail::index_base::final_delete_node_
void final_delete_node_(final_node_type *x)
Definition: index_base.hpp:261
boost::multi_index::detail::index_base::final_replace_
bool final_replace_(const value_type &k, final_node_type *x)
Definition: index_base.hpp:267
boost::multi_index::detail::index_base::insert_
final_node_type * insert_(const value_type &v, final_node_type *&x, rvalue_tag)
Definition: index_base.hpp:115
boost::multi_index::detail::index_base::final_modify_
bool final_modify_(Modifier &mod, final_node_type *x)
Definition: index_base.hpp:275
boost::multi_index::detail::emplaced_tag
Definition: index_base.hpp:52
boost::multi_index::detail::index_node_base
Definition: index_node_base.hpp:46
boost::multi_index::detail::index_base::insert_
final_node_type * insert_(const value_type &v, final_node_type *&x, lvalue_tag)
Definition: index_base.hpp:101
boost::multi_index::detail::index_base::save_
void save_(Archive &, const unsigned int, const index_saver_type &) const
Definition: index_base.hpp:195
boost::multi_index::detail::index_base::final_insert_
std::pair< final_node_type *, bool > final_insert_(const value_type &x, final_node_type *position)
Definition: index_base.hpp:236
boost::multi_index::detail::index_base::swap_
void swap_(index_base< Value, IndexSpecifierList, Allocator > &)
Definition: index_base.hpp:171
boost::multi_index::detail::index_base::final_erase_
void final_erase_(final_node_type *x)
Definition: index_base.hpp:259
boost::multi_index::detail::rvalue_tag
Definition: index_base.hpp:51
boost::multi_index::detail::copy_map
Definition: copy_map.hpp:58
boost::multi_index::detail::index_base::erase_
void erase_(node_type *x)
Definition: index_base.hpp:159
boost::multi_index::detail::index_base::node_type
index_node_base< Value, Allocator > node_type
Definition: index_base.hpp:58
boost::multi_index::detail::index_base::final_insert_ref_
std::pair< final_node_type *, bool > final_insert_ref_(T &t)
Definition: index_base.hpp:226
BOOST_TRY
#define BOOST_TRY
Definition: core/no_exceptions_support.hpp:27
boost::multi_index::detail::index_base::index_loader_type
index_loader< node_type, final_node_type, final_allocator_type > index_loader_type
Definition: index_base.hpp:83
vartempl_support.hpp
BOOST_CATCH
#define BOOST_CATCH(x)
Definition: core/no_exceptions_support.hpp:28
BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK
#define BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK
Definition: vartempl_support.hpp:209
allocator_utilities.hpp
boost::multi_index::detail::index_base::final_swap_
void final_swap_(final_type &x)
Definition: index_base.hpp:265
boost::multi_index::detail::index_base::load_
void load_(Archive &, const unsigned int, const index_loader_type &)
Definition: index_base.hpp:198
boost::multi_index::detail::index_base::insert_
final_node_type * insert_(const value_type &v, node_type *, final_node_type *&x, lvalue_tag)
Definition: index_base.hpp:141
boost::detail::allocator::construct
void construct(void *p, const Type &t)
Definition: allocator_utilities.hpp:151
index_loader.hpp
boost::multi_index::detail::index_base::swap_elements_
void swap_elements_(index_base< Value, IndexSpecifierList, Allocator > &)
Definition: index_base.hpp:173
boost::multi_index::detail::index_base::index_saver_type
index_saver< node_type, final_allocator_type > index_saver_type
Definition: index_base.hpp:79
utility.hpp
boost::multi_index::detail::index_base::value_type
Value value_type
Definition: index_base.hpp:87
boost::multi_index::detail::index_base::final_insert_rv_
std::pair< final_node_type *, bool > final_insert_rv_(const value_type &x, final_node_type *position)
Definition: index_base.hpp:239
BOOST_RETHROW
#define BOOST_RETHROW
Definition: core/no_exceptions_support.hpp:29
boost::multi_index::detail::index_base::replace_
bool replace_(const value_type &v, node_type *x, rvalue_tag)
Definition: index_base.hpp:181
boost::tuples::null_type
Definition: tuple_basic.hpp:53
node_type.hpp
boost::multi_index::detail::index_base::final_replace_rv_
bool final_replace_rv_(const value_type &k, final_node_type *x)
Definition: index_base.hpp:270
boost::mpl::vector0<>
BOOST_CATCH_END
#define BOOST_CATCH_END
Definition: core/no_exceptions_support.hpp:30
core.hpp
boost::multi_index::detail::index_base::const_iterator_type_list
mpl::vector0 const_iterator_type_list
Definition: index_base.hpp:71
boost::multi_index::detail::index_base::final_insert_ref_
std::pair< final_node_type *, bool > final_insert_ref_(const T &t, final_node_type *position)
Definition: index_base.hpp:243
boost::multi_index::detail::index_base::delete_node_
void delete_node_(node_type *x)
Definition: index_base.hpp:164
boost::move
BOOST_MOVE_FORCEINLINE ::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
Definition: utility_core.hpp:212
boost::multi_index::detail::index_base::insert_
final_node_type * insert_(const value_type &, final_node_type *&x, emplaced_tag)
Definition: index_base.hpp:136
boost::multi_index::detail::index_base::final_type
multi_index_container< Value, IndexSpecifierList, Allocator > final_type
Definition: index_base.hpp:62
boost::multi_index::detail::index_base::final_emplace_hint_
std::pair< final_node_type *, bool > final_emplace_hint_(final_node_type *position, BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK)
Definition: index_base.hpp:252
do_not_copy_elements_tag.hpp
header
const std::string header
boost::multi_index::detail::index_node_base::value
value_type & value()
Definition: index_node_base.hpp:52
boost::multi_index::detail::index_base::clear_
void clear_()
Definition: index_base.hpp:169
boost::multi_index::detail::index_base::copy_map_type
copy_map< final_node_type, final_allocator_type > copy_map_type
Definition: index_base.hpp:74
workaround.hpp
boost::detail::allocator::destroy
void destroy(const Type *p)
Definition: allocator_utilities.hpp:166
boost::multi_index::multi_index_container
Definition: multi_index_container.hpp:84
boost::multi_index::detail::index_base::replace_
bool replace_(const value_type &v, node_type *x, lvalue_tag)
Definition: index_base.hpp:175
boost::multi_index::detail::index_base::final_delete_all_nodes_
void final_delete_all_nodes_()
Definition: index_base.hpp:262
boost::multi_index::detail::index_base::iterator_type_list
mpl::vector0 iterator_type_list
Definition: index_base.hpp:70
BOOST_MULTI_INDEX_FORWARD_PARAM_PACK
#define BOOST_MULTI_INDEX_FORWARD_PARAM_PACK
Definition: vartempl_support.hpp:210


sick_visionary_ros
Author(s): SICK AG TechSupport 3D Snapshot
autogenerated on Thu Feb 8 2024 03:39:49