File indexing completed on 2025-01-30 09:48:17
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_MULTI_INDEX_DETAIL_INDEX_NODE_BASE_HPP
0010 #define BOOST_MULTI_INDEX_DETAIL_INDEX_NODE_BASE_HPP
0011
0012 #if defined(_MSC_VER)
0013 #pragma once
0014 #endif
0015
0016 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
0017 #include <boost/type_traits/aligned_storage.hpp>
0018 #include <boost/type_traits/alignment_of.hpp>
0019
0020 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
0021 #include <boost/core/serialization.hpp>
0022 #include <boost/multi_index/detail/bad_archive_exception.hpp>
0023 #include <boost/throw_exception.hpp>
0024 #endif
0025
0026 namespace boost{
0027
0028 namespace multi_index{
0029
0030 namespace detail{
0031
0032
0033
0034
0035
0036 template<typename Value>
0037 struct pod_value_holder
0038 {
0039 typename aligned_storage<
0040 sizeof(Value),
0041 alignment_of<Value>::value
0042 >::type space;
0043 };
0044
0045 template<typename Value,typename Allocator>
0046 struct index_node_base:private pod_value_holder<Value>
0047 {
0048 typedef index_node_base base_type;
0049 typedef Value value_type;
0050 typedef Allocator allocator_type;
0051
0052 #include <boost/multi_index/detail/ignore_wstrict_aliasing.hpp>
0053
0054 value_type& value()
0055 {
0056 return *reinterpret_cast<value_type*>(&this->space);
0057 }
0058
0059 const value_type& value()const
0060 {
0061 return *reinterpret_cast<const value_type*>(&this->space);
0062 }
0063
0064 #include <boost/multi_index/detail/restore_wstrict_aliasing.hpp>
0065
0066 static index_node_base* from_value(const value_type* p)
0067 {
0068 return static_cast<index_node_base *>(
0069 reinterpret_cast<pod_value_holder<Value>*>(
0070 const_cast<value_type*>(p)));
0071 }
0072
0073 private:
0074 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
0075 friend class boost::serialization::access;
0076
0077
0078
0079
0080
0081
0082 template<class Archive>
0083 void serialize(Archive&,const unsigned int)
0084 {
0085 }
0086 #endif
0087 };
0088
0089 template<typename Node,typename Value>
0090 Node* node_from_value(const Value* p)
0091 {
0092 typedef typename Node::allocator_type allocator_type;
0093 return static_cast<Node*>(
0094 index_node_base<Value,allocator_type>::from_value(p));
0095 }
0096
0097 }
0098
0099 }
0100
0101 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
0102
0103
0104
0105
0106
0107
0108 #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
0109 namespace serialization{
0110 #else
0111 namespace multi_index{
0112 namespace detail{
0113 #endif
0114
0115 template<class Archive,typename Value,typename Allocator>
0116 inline void load_construct_data(
0117 Archive&,boost::multi_index::detail::index_node_base<Value,Allocator>*,
0118 const unsigned int)
0119 {
0120 throw_exception(boost::multi_index::detail::bad_archive_exception());
0121 }
0122
0123 #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
0124 }
0125 #else
0126 }
0127 }
0128 #endif
0129
0130 #endif
0131
0132 }
0133
0134 #endif