epoc32/include/stdapis/boost/multi_index/detail/header_holder.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/multi_index/detail/header_holder.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,50 @@
     1.4 +/* Copyright 2003-2005 Joaquín M López Muñoz.
     1.5 + * Distributed under the Boost Software License, Version 1.0.
     1.6 + * (See accompanying file LICENSE_1_0.txt or copy at
     1.7 + * http://www.boost.org/LICENSE_1_0.txt)
     1.8 + *
     1.9 + * See http://www.boost.org/libs/multi_index for library home page.
    1.10 + */
    1.11 +
    1.12 +#ifndef BOOST_MULTI_INDEX_DETAIL_HEADER_HOLDER_HPP
    1.13 +#define BOOST_MULTI_INDEX_DETAIL_HEADER_HOLDER_HPP
    1.14 +
    1.15 +#if defined(_MSC_VER)&&(_MSC_VER>=1200)
    1.16 +#pragma once
    1.17 +#endif
    1.18 +
    1.19 +#include <boost/noncopyable.hpp>
    1.20 +
    1.21 +namespace boost{
    1.22 +
    1.23 +namespace multi_index{
    1.24 +
    1.25 +namespace detail{
    1.26 +
    1.27 +/* A utility class used to hold a pointer to the header node.
    1.28 + * The base from member idiom is used because index classes, which are
    1.29 + * superclasses of multi_index_container, need this header in construction
    1.30 + * time. The allocation is made by the allocator of the multi_index_container
    1.31 + * class --hence, this allocator needs also be stored resorting
    1.32 + * to the base from member trick.
    1.33 + */
    1.34 +
    1.35 +template<typename NodeType,typename Final>
    1.36 +struct header_holder:private noncopyable
    1.37 +{
    1.38 +  header_holder():member(final().allocate_node()){}
    1.39 +  ~header_holder(){final().deallocate_node(member);}
    1.40 +
    1.41 +  NodeType* member;
    1.42 +
    1.43 +private:
    1.44 +  Final& final(){return *static_cast<Final*>(this);}
    1.45 +};
    1.46 +
    1.47 +} /* namespace multi_index::detail */
    1.48 +
    1.49 +} /* namespace multi_index */
    1.50 +
    1.51 +} /* namespace boost */
    1.52 +
    1.53 +#endif