///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2014-2014 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/intrusive for documentation. // ///////////////////////////////////////////////////////////////////////////// #ifndef BOOST_INTRUSIVE_DETAIL_NODE_TO_VALUE_HPP #define BOOST_INTRUSIVE_DETAIL_NODE_TO_VALUE_HPP #ifndef BOOST_CONFIG_HPP # include #endif #if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif #include #include #include namespace boost { namespace intrusive { namespace detail { template struct dummy_constptr { typedef typename boost::intrusive::pointer_traits:: template rebind_pointer::type ConstVoidPtr; explicit dummy_constptr(ConstVoidPtr) {} dummy_constptr() {} ConstVoidPtr get_ptr() const { return ConstVoidPtr(); } }; template struct constptr { typedef typename boost::intrusive::pointer_traits:: template rebind_pointer::type ConstVoidPtr; constptr() {} explicit constptr(const ConstVoidPtr &ptr) : const_void_ptr_(ptr) {} const void *get_ptr() const { return boost::movelib::to_raw_pointer(const_void_ptr_); } ConstVoidPtr const_void_ptr_; }; template struct select_constptr { typedef typename if_c < store_ptr , constptr , dummy_constptr >::type type; }; template struct node_to_value : public select_constptr < typename pointer_traits ::template rebind_pointer::type , is_stateful_value_traits::value >::type { static const bool stateful_value_traits = is_stateful_value_traits::value; typedef typename select_constptr < typename pointer_traits :: template rebind_pointer::type , stateful_value_traits >::type Base; typedef ValueTraits value_traits; typedef typename value_traits::value_type value_type; typedef typename value_traits::node_traits::node node; typedef typename add_const_if_c ::type vtype; typedef typename add_const_if_c ::type ntype; typedef typename pointer_traits :: template rebind_pointer::type npointer; typedef typename pointer_traits:: template rebind_pointer::type const_value_traits_ptr; node_to_value(const_value_traits_ptr ptr) : Base(ptr) {} typedef vtype & result_type; typedef ntype & first_argument_type; const_value_traits_ptr get_value_traits() const { return pointer_traits::static_cast_from(Base::get_ptr()); } result_type to_value(first_argument_type arg, false_) const { return *(value_traits::to_value_ptr(pointer_traits::pointer_to(arg))); } result_type to_value(first_argument_type arg, true_) const { return *(this->get_value_traits()->to_value_ptr(pointer_traits::pointer_to(arg))); } result_type operator()(first_argument_type arg) const { return this->to_value(arg, bool_()); } }; } //namespace detail{ } //namespace intrusive{ } //namespace boost{ #endif //BOOST_INTRUSIVE_DETAIL_NODE_TO_VALUE_HPP