Chris@16: /* Copyright 2003-2008 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_HEADER_HOLDER_HPP Chris@16: #define BOOST_MULTI_INDEX_DETAIL_HEADER_HOLDER_HPP Chris@16: Chris@101: #if defined(_MSC_VER) Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost{ Chris@16: Chris@16: namespace multi_index{ Chris@16: Chris@16: namespace detail{ Chris@16: Chris@16: /* A utility class used to hold a pointer to the header node. Chris@16: * The base from member idiom is used because index classes, which are Chris@16: * superclasses of multi_index_container, need this header in construction Chris@16: * time. The allocation is made by the allocator of the multi_index_container Chris@16: * class --hence, this allocator needs also be stored resorting Chris@16: * to the base from member trick. Chris@16: */ Chris@16: Chris@16: template Chris@16: struct header_holder:private noncopyable Chris@16: { Chris@16: header_holder():member(final().allocate_node()){} Chris@16: ~header_holder(){final().deallocate_node(&*member);} Chris@16: Chris@16: NodeTypePtr member; Chris@16: Chris@16: private: Chris@16: Final& final(){return *static_cast(this);} Chris@16: }; Chris@16: Chris@16: } /* namespace multi_index::detail */ Chris@16: Chris@16: } /* namespace multi_index */ Chris@16: Chris@16: } /* namespace boost */ Chris@16: Chris@16: #endif