annotate DEPENDENCIES/generic/include/boost/multi_index/detail/index_node_base.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@101 1 /* Copyright 2003-2013 Joaquin M Lopez Munoz.
Chris@16 2 * Distributed under the Boost Software License, Version 1.0.
Chris@16 3 * (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 4 * http://www.boost.org/LICENSE_1_0.txt)
Chris@16 5 *
Chris@16 6 * See http://www.boost.org/libs/multi_index for library home page.
Chris@16 7 */
Chris@16 8
Chris@16 9 #ifndef BOOST_MULTI_INDEX_DETAIL_INDEX_NODE_BASE_HPP
Chris@16 10 #define BOOST_MULTI_INDEX_DETAIL_INDEX_NODE_BASE_HPP
Chris@16 11
Chris@101 12 #if defined(_MSC_VER)
Chris@16 13 #pragma once
Chris@16 14 #endif
Chris@16 15
Chris@16 16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
Chris@16 17 #include <boost/type_traits/aligned_storage.hpp>
Chris@16 18 #include <boost/type_traits/alignment_of.hpp>
Chris@16 19
Chris@16 20 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
Chris@16 21 #include <boost/archive/archive_exception.hpp>
Chris@16 22 #include <boost/serialization/access.hpp>
Chris@16 23 #include <boost/throw_exception.hpp>
Chris@16 24 #endif
Chris@16 25
Chris@16 26 namespace boost{
Chris@16 27
Chris@16 28 namespace multi_index{
Chris@16 29
Chris@16 30 namespace detail{
Chris@16 31
Chris@16 32 /* index_node_base tops the node hierarchy of multi_index_container. It holds
Chris@16 33 * the value of the element contained.
Chris@16 34 */
Chris@16 35
Chris@16 36 template<typename Value>
Chris@16 37 struct pod_value_holder
Chris@16 38 {
Chris@16 39 typename aligned_storage<
Chris@16 40 sizeof(Value),
Chris@16 41 alignment_of<Value>::value
Chris@16 42 >::type space;
Chris@16 43 };
Chris@16 44
Chris@16 45 template<typename Value,typename Allocator>
Chris@16 46 struct index_node_base:private pod_value_holder<Value>
Chris@16 47 {
Chris@16 48 typedef index_node_base base_type; /* used for serialization purposes */
Chris@16 49 typedef Value value_type;
Chris@16 50 typedef Allocator allocator_type;
Chris@16 51
Chris@16 52 value_type& value()
Chris@16 53 {
Chris@16 54 return *static_cast<value_type*>(
Chris@16 55 static_cast<void*>(&this->space));
Chris@16 56 }
Chris@16 57
Chris@16 58 const value_type& value()const
Chris@16 59 {
Chris@16 60 return *static_cast<const value_type*>(
Chris@16 61 static_cast<const void*>(&this->space));
Chris@16 62 }
Chris@16 63
Chris@16 64 static index_node_base* from_value(const value_type* p)
Chris@16 65 {
Chris@16 66 return static_cast<index_node_base *>(
Chris@16 67 reinterpret_cast<pod_value_holder<Value>*>( /* std 9.2.17 */
Chris@16 68 const_cast<value_type*>(p)));
Chris@16 69 }
Chris@16 70
Chris@16 71 private:
Chris@16 72 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
Chris@16 73 friend class boost::serialization::access;
Chris@16 74
Chris@16 75 /* nodes do not emit any kind of serialization info. They are
Chris@16 76 * fed to Boost.Serialization so that pointers to nodes are
Chris@16 77 * tracked correctly.
Chris@16 78 */
Chris@16 79
Chris@16 80 template<class Archive>
Chris@16 81 void serialize(Archive&,const unsigned int)
Chris@16 82 {
Chris@16 83 }
Chris@16 84 #endif
Chris@16 85 };
Chris@16 86
Chris@16 87 template<typename Node,typename Value>
Chris@101 88 Node* node_from_value(const Value* p)
Chris@16 89 {
Chris@16 90 typedef typename Node::allocator_type allocator_type;
Chris@16 91 return static_cast<Node*>(
Chris@16 92 index_node_base<Value,allocator_type>::from_value(p));
Chris@16 93 }
Chris@16 94
Chris@16 95 } /* namespace multi_index::detail */
Chris@16 96
Chris@16 97 } /* namespace multi_index */
Chris@16 98
Chris@16 99 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
Chris@16 100 /* Index nodes never get constructed directly by Boost.Serialization,
Chris@16 101 * as archives are always fed pointers to previously existent
Chris@16 102 * nodes. So, if this is called it means we are dealing with a
Chris@16 103 * somehow invalid archive.
Chris@16 104 */
Chris@16 105
Chris@16 106 #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
Chris@16 107 namespace serialization{
Chris@16 108 #else
Chris@16 109 namespace multi_index{
Chris@16 110 namespace detail{
Chris@16 111 #endif
Chris@16 112
Chris@16 113 template<class Archive,typename Value,typename Allocator>
Chris@16 114 inline void load_construct_data(
Chris@16 115 Archive&,boost::multi_index::detail::index_node_base<Value,Allocator>*,
Chris@16 116 const unsigned int)
Chris@16 117 {
Chris@16 118 throw_exception(
Chris@16 119 archive::archive_exception(archive::archive_exception::other_exception));
Chris@16 120 }
Chris@16 121
Chris@16 122 #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
Chris@16 123 } /* namespace serialization */
Chris@16 124 #else
Chris@16 125 } /* namespace multi_index::detail */
Chris@16 126 } /* namespace multi_index */
Chris@16 127 #endif
Chris@16 128
Chris@16 129 #endif
Chris@16 130
Chris@16 131 } /* namespace boost */
Chris@16 132
Chris@16 133 #endif