source: NonGTP/Boost/boost/multi_index/detail/header_holder.hpp @ 857

Revision 857, 1.5 KB checked in by igarcia, 19 years ago (diff)
Line 
1/* Copyright 2003-2005 Joaquín M López Muñoz.
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_HEADER_HOLDER_HPP
10#define BOOST_MULTI_INDEX_DETAIL_HEADER_HOLDER_HPP
11
12#if defined(_MSC_VER)&&(_MSC_VER>=1200)
13#pragma once
14#endif
15
16#include <boost/noncopyable.hpp>
17#include <boost/utility/base_from_member.hpp>
18
19namespace boost{
20
21namespace multi_index{
22
23namespace detail{
24
25/* An utility class derived from base_from_member used to hold
26 * a pointer to the header node. The base from member idiom is used
27 * because index classes, which are superclasses of multi_index_container,
28 * need this header in construction time.
29 * The allocation is made by the allocator of the multi_index_container
30 * class --hence, this allocator needs also be stored resorting
31 * to the base from member trick.
32 */
33
34template<typename NodeType,typename Final>
35struct header_holder:base_from_member<NodeType*>,private noncopyable
36{
37  header_holder():super(final().allocate_node()){}
38  ~header_holder(){final().deallocate_node(super::member);}
39
40private:
41  typedef base_from_member<NodeType*> super;
42  Final& final(){return *static_cast<Final*>(this);}
43};
44
45} /* namespace multi_index::detail */
46
47} /* namespace multi_index */
48
49} /* namespace boost */
50
51#endif
Note: See TracBrowser for help on using the repository browser.