Chris@101: /* Copyright 2003-2013 Joaquin M Lopez Munoz. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: * Chris@16: * See http://www.boost.org/libs/multi_index for library home page. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_MULTI_INDEX_DETAIL_INDEX_NODE_BASE_HPP Chris@16: #define BOOST_MULTI_INDEX_DETAIL_INDEX_NODE_BASE_HPP Chris@16: Chris@101: #if defined(_MSC_VER) Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: #include /* keep it first to prevent nasty warns in MSVC */ Chris@16: #include Chris@16: #include Chris@16: Chris@16: #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #endif Chris@16: Chris@16: namespace boost{ Chris@16: Chris@16: namespace multi_index{ Chris@16: Chris@16: namespace detail{ Chris@16: Chris@16: /* index_node_base tops the node hierarchy of multi_index_container. It holds Chris@16: * the value of the element contained. Chris@16: */ Chris@16: Chris@16: template Chris@16: struct pod_value_holder Chris@16: { Chris@16: typename aligned_storage< Chris@16: sizeof(Value), Chris@16: alignment_of::value Chris@16: >::type space; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct index_node_base:private pod_value_holder Chris@16: { Chris@16: typedef index_node_base base_type; /* used for serialization purposes */ Chris@16: typedef Value value_type; Chris@16: typedef Allocator allocator_type; Chris@16: Chris@16: value_type& value() Chris@16: { Chris@16: return *static_cast( Chris@16: static_cast(&this->space)); Chris@16: } Chris@16: Chris@16: const value_type& value()const Chris@16: { Chris@16: return *static_cast( Chris@16: static_cast(&this->space)); Chris@16: } Chris@16: Chris@16: static index_node_base* from_value(const value_type* p) Chris@16: { Chris@16: return static_cast( Chris@16: reinterpret_cast*>( /* std 9.2.17 */ Chris@16: const_cast(p))); Chris@16: } Chris@16: Chris@16: private: Chris@16: #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) Chris@16: friend class boost::serialization::access; Chris@16: Chris@16: /* nodes do not emit any kind of serialization info. They are Chris@16: * fed to Boost.Serialization so that pointers to nodes are Chris@16: * tracked correctly. Chris@16: */ Chris@16: Chris@16: template Chris@16: void serialize(Archive&,const unsigned int) Chris@16: { Chris@16: } Chris@16: #endif Chris@16: }; Chris@16: Chris@16: template Chris@101: Node* node_from_value(const Value* p) Chris@16: { Chris@16: typedef typename Node::allocator_type allocator_type; Chris@16: return static_cast( Chris@16: index_node_base::from_value(p)); Chris@16: } Chris@16: Chris@16: } /* namespace multi_index::detail */ Chris@16: Chris@16: } /* namespace multi_index */ Chris@16: Chris@16: #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION) Chris@16: /* Index nodes never get constructed directly by Boost.Serialization, Chris@16: * as archives are always fed pointers to previously existent Chris@16: * nodes. So, if this is called it means we are dealing with a Chris@16: * somehow invalid archive. Chris@16: */ Chris@16: Chris@16: #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) Chris@16: namespace serialization{ Chris@16: #else Chris@16: namespace multi_index{ Chris@16: namespace detail{ Chris@16: #endif Chris@16: Chris@16: template Chris@16: inline void load_construct_data( Chris@16: Archive&,boost::multi_index::detail::index_node_base*, Chris@16: const unsigned int) Chris@16: { Chris@16: throw_exception( Chris@16: archive::archive_exception(archive::archive_exception::other_exception)); Chris@16: } Chris@16: Chris@16: #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) Chris@16: } /* namespace serialization */ Chris@16: #else Chris@16: } /* namespace multi_index::detail */ Chris@16: } /* namespace multi_index */ Chris@16: #endif Chris@16: Chris@16: #endif Chris@16: Chris@16: } /* namespace boost */ Chris@16: Chris@16: #endif