Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:37

0001 /////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga  2014-2014
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 //    (See accompanying file LICENSE_1_0.txt or copy at
0007 //          http://www.boost.org/LICENSE_1_0.txt)
0008 //
0009 // See http://www.boost.org/libs/intrusive for documentation.
0010 //
0011 /////////////////////////////////////////////////////////////////////////////
0012 
0013 #ifndef BOOST_INTRUSIVE_DETAIL_NODE_CLONER_DISPOSER_HPP
0014 #define BOOST_INTRUSIVE_DETAIL_NODE_CLONER_DISPOSER_HPP
0015 
0016 #ifndef BOOST_CONFIG_HPP
0017 #  include <boost/config.hpp>
0018 #endif
0019 
0020 #if defined(BOOST_HAS_PRAGMA_ONCE)
0021 #  pragma once
0022 #endif
0023 
0024 #include <boost/intrusive/link_mode.hpp>
0025 #include <boost/intrusive/detail/mpl.hpp>
0026 #include <boost/intrusive/detail/ebo_functor_holder.hpp>
0027 #include <boost/intrusive/detail/algo_type.hpp>
0028 #include <boost/intrusive/detail/assert.hpp>
0029 
0030 namespace boost {
0031 namespace intrusive {
0032 namespace detail {
0033 
0034 template<class F, class ValueTraits, algo_types AlgoType, bool IsConst = true>
0035 struct node_cloner
0036    //Use public inheritance to avoid MSVC bugs with closures
0037    :  public ebo_functor_holder<F>
0038 {
0039    typedef ValueTraits                                      value_traits;
0040    typedef typename value_traits::node_traits               node_traits;
0041    typedef typename node_traits::node_ptr                   node_ptr;
0042    typedef ebo_functor_holder<F>                            base_t;
0043    typedef typename get_algo< AlgoType
0044                             , node_traits>::type            node_algorithms;
0045    static const bool safemode_or_autounlink =
0046       is_safe_autounlink<value_traits::link_mode>::value;
0047    typedef typename value_traits::value_type                value_type;
0048    typedef typename value_traits::pointer                   pointer;
0049    typedef typename value_traits::const_pointer             const_pointer;
0050    typedef typename node_traits::node                       node;
0051    typedef typename value_traits::const_node_ptr            const_node_ptr;
0052    typedef typename pointer_traits<pointer>::reference      reference;
0053    typedef typename pointer_traits
0054       <const_pointer>::reference                            const_reference;
0055    typedef typename if_c<IsConst, const_reference, reference>::type reference_type;
0056 
0057    node_cloner(F f, const ValueTraits *traits)
0058       :  base_t(f), traits_(traits)
0059    {}
0060 
0061    // tree-based containers use this method, which is proxy-reference friendly
0062    BOOST_INTRUSIVE_FORCEINLINE node_ptr operator()(node_ptr p)
0063    {
0064       reference_type v = *traits_->to_value_ptr(p);
0065       node_ptr n = traits_->to_node_ptr(*base_t::get()(v));
0066       //Cloned node must be in default mode if the linking mode requires it
0067       BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(n));
0068       return n;
0069    }
0070 
0071    const ValueTraits * const traits_;
0072 };
0073 
0074 template<class F, class ValueTraits, algo_types AlgoType>
0075 struct node_disposer
0076    //Use public inheritance to avoid MSVC bugs with closures
0077    :  public ebo_functor_holder<F>
0078 {
0079    typedef ValueTraits                          value_traits;
0080    typedef typename value_traits::node_traits   node_traits;
0081    typedef typename node_traits::node_ptr       node_ptr;
0082    typedef ebo_functor_holder<F>                base_t;
0083    typedef typename get_algo< AlgoType
0084                             , node_traits>::type   node_algorithms;
0085    static const bool safemode_or_autounlink =
0086       is_safe_autounlink<value_traits::link_mode>::value;
0087 
0088    BOOST_INTRUSIVE_FORCEINLINE node_disposer(F f, const ValueTraits *cont)
0089       :  base_t(f), traits_(cont)
0090    {}
0091 
0092    BOOST_INTRUSIVE_FORCEINLINE void operator()(node_ptr p)
0093    {
0094       BOOST_IF_CONSTEXPR(safemode_or_autounlink)
0095          node_algorithms::init(p);
0096       base_t::get()(traits_->to_value_ptr(p));
0097    }
0098    const ValueTraits * const traits_;
0099 };
0100 
0101 }  //namespace detail{
0102 }  //namespace intrusive{
0103 }  //namespace boost{
0104 
0105 #endif //BOOST_INTRUSIVE_DETAIL_NODE_CLONER_DISPOSER_HPP