Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:48:17

0001 /* Copyright 2003-2022 Joaquin M Lopez Munoz.
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * See http://www.boost.org/libs/multi_index for library home page.
0007  */
0008 
0009 #ifndef BOOST_MULTI_INDEX_DETAIL_HEADER_HOLDER_HPP
0010 #define BOOST_MULTI_INDEX_DETAIL_HEADER_HOLDER_HPP
0011 
0012 #if defined(_MSC_VER)
0013 #pragma once
0014 #endif
0015 
0016 #include <boost/core/noncopyable.hpp>
0017 
0018 namespace boost{
0019 
0020 namespace multi_index{
0021 
0022 namespace detail{
0023 
0024 /* A utility class used to hold a pointer to the header node.
0025  * The base from member idiom is used because index classes, which are
0026  * superclasses of multi_index_container, need this header in construction
0027  * time. The allocation is made by the allocator of the multi_index_container
0028  * class --hence, this allocator needs also be stored resorting
0029  * to the base from member trick.
0030  */
0031 
0032 template<typename NodeTypePtr,typename Final>
0033 struct header_holder:private noncopyable
0034 {
0035   header_holder():member(final().allocate_node()){}
0036   ~header_holder(){final().deallocate_node(&*member);}
0037 
0038   NodeTypePtr member;
0039 
0040 private:
0041   Final& final(){return *static_cast<Final*>(this);}
0042 };
0043 
0044 } /* namespace multi_index::detail */
0045 
0046 } /* namespace multi_index */
0047 
0048 } /* namespace boost */
0049 
0050 #endif