///////////////////////////////////////////////////////////////////////////// // // (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_GET_VALUE_TRAITS_HPP #define BOOST_INTRUSIVE_DETAIL_GET_VALUE_TRAITS_HPP #if defined(_MSC_VER) # pragma once #endif #include #include #include namespace boost { namespace intrusive { #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED template struct is_default_hook_tag { static const bool value = false; }; namespace detail{ template struct concrete_hook_base_value_traits { typedef typename BaseHook::hooktags tags; typedef bhtraits < T , typename tags::node_traits , tags::link_mode , typename tags::tag , tags::type> type; }; template struct concrete_hook_base_value_traits { typedef typename BaseHook::hooktags type; }; template struct any_hook_base_value_traits { //AnyToSomeHook value_traits derive from a generic_hook //The generic_hook is configured with any_node_traits //and AnyToSomeHook::value_traits with the correct //node traits for the container, so use node_traits //from AnyToSomeHook_ProtoValueTraits and the rest of //elements from the hooktags member of the generic_hook typedef typename AnyToSomeHook_ProtoValueTraits::basic_hook_t basic_hook_t; typedef typename pointer_rebind < typename basic_hook_t::hooktags::node_traits::node_ptr , void>::type void_pointer; typedef typename AnyToSomeHook_ProtoValueTraits::template node_traits_from_voidptr::type node_traits; typedef bhtraits < T , node_traits , basic_hook_t::hooktags::link_mode , typename basic_hook_t::hooktags::tag , basic_hook_t::hooktags::type > type; }; template struct any_hook_base_value_traits { typedef typename AnyToSomeHook_ProtoValueTraits::basic_hook_t basic_hook_t; typedef typename pointer_rebind < typename basic_hook_t::hooktags::node_traits::node_ptr , void>::type void_pointer; struct type { typedef typename AnyToSomeHook_ProtoValueTraits::template node_traits_from_voidptr::type node_traits; }; }; template struct get_member_value_traits { typedef typename MemberHook::member_value_traits type; }; BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_any_hook, is_any_hook) BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_base_hook, hooktags::is_base_hook) template struct internal_member_value_traits { template static one test(...); template static two test(typename U::member_value_traits* = 0); static const bool value = sizeof(test(0)) == sizeof(two); }; template::value> struct supposed_value_traits; template::value> struct get_base_value_traits; template::value> struct supposed_base_value_traits; template::value> struct supposed_member_value_traits; template::value> struct any_or_concrete_value_traits; //Base any hook template struct get_base_value_traits : any_hook_base_value_traits {}; //Non-any base hook template struct get_base_value_traits : concrete_hook_base_value_traits {}; //...It's a default hook template struct supposed_value_traits { typedef typename SupposedValueTraits::template apply::type type; }; //...Not a default hook template struct supposed_value_traits { typedef SupposedValueTraits type; }; //...It's a base hook template struct supposed_base_value_traits : get_base_value_traits {}; //...Not a base hook, try if it's a member or value_traits template struct supposed_base_value_traits : supposed_member_value_traits {}; //...It's a member hook template struct supposed_member_value_traits : get_member_value_traits {}; //...Not a member hook template struct supposed_member_value_traits : any_or_concrete_value_traits {}; template struct any_or_concrete_value_traits { //A hook node (non-base, e.g.: member or other value traits typedef typename AnyToSomeHook_ProtoValueTraits::basic_hook_t basic_hook_t; typedef typename pointer_rebind ::type void_pointer; typedef typename AnyToSomeHook_ProtoValueTraits::template node_traits_from_voidptr::type any_node_traits; struct type : basic_hook_t { typedef any_node_traits node_traits; }; }; template struct any_or_concrete_value_traits { typedef SupposedValueTraits type; }; //////////////////////////////////////// // get_value_traits / get_node_traits //////////////////////////////////////// template struct get_value_traits : supposed_base_value_traits::type, T> {}; template struct get_node_traits { typedef typename get_value_traits::type::node_traits type; }; } //namespace detail{ #endif //BOOST_INTRUSIVE_DOXYGEN_INVOKED } //namespace intrusive { } //namespace boost { #include #endif //#ifndef BOOST_INTRUSIVE_DETAIL_GET_VALUE_TRAITS_HPP