summaryrefslogtreecommitdiff
path: root/boost/intrusive/detail/node_cloner_disposer.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/intrusive/detail/node_cloner_disposer.hpp')
-rw-r--r--boost/intrusive/detail/node_cloner_disposer.hpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/boost/intrusive/detail/node_cloner_disposer.hpp b/boost/intrusive/detail/node_cloner_disposer.hpp
index 2a18100205..65af3e37b8 100644
--- a/boost/intrusive/detail/node_cloner_disposer.hpp
+++ b/boost/intrusive/detail/node_cloner_disposer.hpp
@@ -13,11 +13,16 @@
#ifndef BOOST_INTRUSIVE_DETAIL_NODE_CLONER_DISPOSER_HPP
#define BOOST_INTRUSIVE_DETAIL_NODE_CLONER_DISPOSER_HPP
-#if defined(_MSC_VER)
+#ifndef BOOST_CONFIG_HPP
+# include <boost/config.hpp>
+#endif
+
+#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <boost/intrusive/link_mode.hpp>
+#include <boost/intrusive/detail/mpl.hpp>
#include <boost/intrusive/detail/ebo_functor_holder.hpp>
#include <boost/intrusive/detail/algo_type.hpp>
#include <boost/intrusive/detail/assert.hpp>
@@ -26,9 +31,10 @@ namespace boost {
namespace intrusive {
namespace detail {
-template<class F, class ValueTraits, algo_types AlgoType>
+template<class F, class ValueTraits, algo_types AlgoType, bool IsConst = true>
struct node_cloner
- : private ebo_functor_holder<F>
+ //Use public inheritance to avoid MSVC bugs with closures
+ : public ebo_functor_holder<F>
{
typedef ValueTraits value_traits;
typedef typename value_traits::node_traits node_traits;
@@ -45,6 +51,8 @@ struct node_cloner
typedef typename value_traits::reference reference;
typedef typename value_traits::const_reference const_reference;
+ typedef typename if_c<IsConst, const_reference, reference>::type reference_type;
+
node_cloner(F f, const ValueTraits *traits)
: base_t(f), traits_(traits)
{}
@@ -52,7 +60,7 @@ struct node_cloner
// tree-based containers use this method, which is proxy-reference friendly
node_ptr operator()(const node_ptr & p)
{
- const_reference v = *traits_->to_value_ptr(p);
+ reference_type v = *traits_->to_value_ptr(p);
node_ptr n = traits_->to_node_ptr(*base_t::get()(v));
//Cloned node must be in default mode if the linking mode requires it
if(safemode_or_autounlink)
@@ -63,7 +71,7 @@ struct node_cloner
// hashtables use this method, which is proxy-reference unfriendly
node_ptr operator()(const node &to_clone)
{
- const value_type &v =
+ reference_type v =
*traits_->to_value_ptr
(pointer_traits<const_node_ptr>::pointer_to(to_clone));
node_ptr n = traits_->to_node_ptr(*base_t::get()(v));
@@ -78,7 +86,8 @@ struct node_cloner
template<class F, class ValueTraits, algo_types AlgoType>
struct node_disposer
- : private ebo_functor_holder<F>
+ //Use public inheritance to avoid MSVC bugs with closures
+ : public ebo_functor_holder<F>
{
typedef ValueTraits value_traits;
typedef typename value_traits::node_traits node_traits;