Chris@102: ///////////////////////////////////////////////////////////////////////////// Chris@102: // Chris@102: // (C) Copyright Ion Gaztanaga 2014-2014 Chris@102: // Chris@102: // Distributed under the Boost Software License, Version 1.0. Chris@102: // (See accompanying file LICENSE_1_0.txt or copy at Chris@102: // http://www.boost.org/LICENSE_1_0.txt) Chris@102: // Chris@102: // See http://www.boost.org/libs/intrusive for documentation. Chris@102: // Chris@102: ///////////////////////////////////////////////////////////////////////////// Chris@102: Chris@102: #ifndef BOOST_INTRUSIVE_DETAIL_GET_VALUE_TRAITS_HPP Chris@102: #define BOOST_INTRUSIVE_DETAIL_GET_VALUE_TRAITS_HPP Chris@102: Chris@102: #ifndef BOOST_CONFIG_HPP Chris@102: # include Chris@102: #endif Chris@102: Chris@102: #if defined(BOOST_HAS_PRAGMA_ONCE) Chris@102: # pragma once Chris@102: #endif Chris@102: Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: Chris@102: namespace boost { Chris@102: namespace intrusive { Chris@102: Chris@102: #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED Chris@102: Chris@102: template Chris@102: struct is_default_hook_tag Chris@102: { static const bool value = false; }; Chris@102: Chris@102: namespace detail{ Chris@102: Chris@102: template Chris@102: struct concrete_hook_base_value_traits Chris@102: { Chris@102: typedef typename BaseHook::hooktags tags; Chris@102: typedef bhtraits Chris@102: < T Chris@102: , typename tags::node_traits Chris@102: , tags::link_mode Chris@102: , typename tags::tag Chris@102: , tags::type> type; Chris@102: }; Chris@102: Chris@102: template Chris@102: struct concrete_hook_base_value_traits Chris@102: { Chris@102: typedef typename BaseHook::hooktags type; Chris@102: }; Chris@102: Chris@102: template Chris@102: struct any_hook_base_value_traits Chris@102: { Chris@102: //AnyToSomeHook value_traits derive from a generic_hook Chris@102: //The generic_hook is configured with any_node_traits Chris@102: //and AnyToSomeHook::value_traits with the correct Chris@102: //node traits for the container, so use node_traits Chris@102: //from AnyToSomeHook_ProtoValueTraits and the rest of Chris@102: //elements from the hooktags member of the generic_hook Chris@102: Chris@102: typedef typename AnyToSomeHook_ProtoValueTraits::basic_hook_t basic_hook_t; Chris@102: typedef typename pointer_rebind Chris@102: < typename basic_hook_t::hooktags::node_traits::node_ptr Chris@102: , void>::type void_pointer; Chris@102: typedef typename AnyToSomeHook_ProtoValueTraits::template Chris@102: node_traits_from_voidptr::type node_traits; Chris@102: Chris@102: typedef bhtraits Chris@102: < T Chris@102: , node_traits Chris@102: , basic_hook_t::hooktags::link_mode Chris@102: , typename basic_hook_t::hooktags::tag Chris@102: , basic_hook_t::hooktags::type Chris@102: > type; Chris@102: }; Chris@102: Chris@102: template Chris@102: struct any_hook_base_value_traits Chris@102: { Chris@102: typedef typename AnyToSomeHook_ProtoValueTraits::basic_hook_t basic_hook_t; Chris@102: typedef typename pointer_rebind Chris@102: < typename basic_hook_t::hooktags::node_traits::node_ptr Chris@102: , void>::type void_pointer; Chris@102: Chris@102: struct type Chris@102: { Chris@102: typedef typename AnyToSomeHook_ProtoValueTraits::template Chris@102: node_traits_from_voidptr::type node_traits; Chris@102: }; Chris@102: }; Chris@102: Chris@102: template Chris@102: struct get_member_value_traits Chris@102: { Chris@102: typedef typename MemberHook::member_value_traits type; Chris@102: }; Chris@102: Chris@102: BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_any_hook, is_any_hook) Chris@102: BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_base_hook, hooktags::is_base_hook) Chris@102: Chris@102: template Chris@102: struct internal_member_value_traits Chris@102: { Chris@102: template static one test(...); Chris@102: template static two test(typename U::member_value_traits* = 0); Chris@102: static const bool value = sizeof(test(0)) == sizeof(two); Chris@102: }; Chris@102: Chris@102: template::value> Chris@102: struct supposed_value_traits; Chris@102: Chris@102: template::value> Chris@102: struct get_base_value_traits; Chris@102: Chris@102: template::value> Chris@102: struct supposed_base_value_traits; Chris@102: Chris@102: template::value> Chris@102: struct supposed_member_value_traits; Chris@102: Chris@102: template::value> Chris@102: struct any_or_concrete_value_traits; Chris@102: Chris@102: //Base any hook Chris@102: template Chris@102: struct get_base_value_traits Chris@102: : any_hook_base_value_traits Chris@102: {}; Chris@102: Chris@102: //Non-any base hook Chris@102: template Chris@102: struct get_base_value_traits Chris@102: : concrete_hook_base_value_traits Chris@102: {}; Chris@102: Chris@102: //...It's a default hook Chris@102: template Chris@102: struct supposed_value_traits Chris@102: { typedef typename SupposedValueTraits::template apply::type type; }; Chris@102: Chris@102: //...Not a default hook Chris@102: template Chris@102: struct supposed_value_traits Chris@102: { typedef SupposedValueTraits type; }; Chris@102: Chris@102: //...It's a base hook Chris@102: template Chris@102: struct supposed_base_value_traits Chris@102: : get_base_value_traits Chris@102: {}; Chris@102: Chris@102: //...Not a base hook, try if it's a member or value_traits Chris@102: template Chris@102: struct supposed_base_value_traits Chris@102: : supposed_member_value_traits Chris@102: {}; Chris@102: Chris@102: //...It's a member hook Chris@102: template Chris@102: struct supposed_member_value_traits Chris@102: : get_member_value_traits Chris@102: {}; Chris@102: Chris@102: //...Not a member hook Chris@102: template Chris@102: struct supposed_member_value_traits Chris@102: : any_or_concrete_value_traits Chris@102: {}; Chris@102: Chris@102: template Chris@102: struct any_or_concrete_value_traits Chris@102: { Chris@102: //A hook node (non-base, e.g.: member or other value traits Chris@102: typedef typename AnyToSomeHook_ProtoValueTraits::basic_hook_t basic_hook_t; Chris@102: typedef typename pointer_rebind Chris@102: ::type void_pointer; Chris@102: typedef typename AnyToSomeHook_ProtoValueTraits::template Chris@102: node_traits_from_voidptr::type any_node_traits; Chris@102: Chris@102: struct type : basic_hook_t Chris@102: { Chris@102: typedef any_node_traits node_traits; Chris@102: }; Chris@102: }; Chris@102: Chris@102: template Chris@102: struct any_or_concrete_value_traits Chris@102: { Chris@102: typedef SupposedValueTraits type; Chris@102: }; Chris@102: Chris@102: //////////////////////////////////////// Chris@102: // get_value_traits / get_node_traits Chris@102: //////////////////////////////////////// Chris@102: Chris@102: template Chris@102: struct get_value_traits Chris@102: : supposed_base_value_traits::type, T> Chris@102: {}; Chris@102: Chris@102: template Chris@102: struct get_node_traits Chris@102: { Chris@102: typedef typename get_value_traits::type::node_traits type; Chris@102: }; Chris@102: Chris@102: } //namespace detail{ Chris@102: Chris@102: #endif //BOOST_INTRUSIVE_DOXYGEN_INVOKED Chris@102: Chris@102: } //namespace intrusive { Chris@102: } //namespace boost { Chris@102: Chris@102: #include Chris@102: Chris@102: #endif //#ifndef BOOST_INTRUSIVE_DETAIL_GET_VALUE_TRAITS_HPP