epoc32/include/stdapis/boost/multi_index/detail/header_holder.hpp
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     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 
    18 namespace boost{
    19 
    20 namespace multi_index{
    21 
    22 namespace detail{
    23 
    24 /* A utility class used to hold a pointer to the header node.
    25  * The base from member idiom is used because index classes, which are
    26  * superclasses of multi_index_container, need this header in construction
    27  * time. The allocation is made by the allocator of the multi_index_container
    28  * class --hence, this allocator needs also be stored resorting
    29  * to the base from member trick.
    30  */
    31 
    32 template<typename NodeType,typename Final>
    33 struct header_holder:private noncopyable
    34 {
    35   header_holder():member(final().allocate_node()){}
    36   ~header_holder(){final().deallocate_node(member);}
    37 
    38   NodeType* member;
    39 
    40 private:
    41   Final& final(){return *static_cast<Final*>(this);}
    42 };
    43 
    44 } /* namespace multi_index::detail */
    45 
    46 } /* namespace multi_index */
    47 
    48 } /* namespace boost */
    49 
    50 #endif