2015-10-18 13:03 GMT+02:00 Ion Gaztañaga <igaztanaga@gmail.com>:
On 17/10/2015 18:04, Oliver Kowalke wrote:
I'd like to determine the hook type of an intrusive container
(intrusive::list):

template< typename List >
void do_link( List & lst) {
    static_assert(std::is_same< typename List::???, my_hook_type >::value);
    lst.push_back( * this);
}

Hi,

There is no current typedef for that. The closest thing is "value_traits", which is what the container understands. Each hook type is transformed to "value_traits" which tells the container how the value and the node (stored in the hook) communicate.

If "value_traits" option is passed instead of a hook, then container::value_traits is the same type. If a hook is passed (or deduced, if the default hook is used), then that information is transformed in a "value_traits" defined here:

boost/intrusive/hook_traits.hpp

(e.g. boost::intrusive::detail::bhtraits<T, NodeTraits, LinkMode, Tag, Type> for a base hook).

If this information is important, then we should design a better interface to check it. "value_traits" is not a very good name for what it does, maybe "hook_traits" would have been a better name. The issue is that a "hook" (which could be deduced form "value_type" if the programmer does not provide it) is not directly transformed on what the container really uses ("value_traits").

Best,

Ion

thx, using value_traits::hook_type helps

template< typename List >
void do_link( List & lst) {
    static_assert(std::is_same< typename List::value_traits::hook_type, my_hook_type >::value);
    lst.push_back( * this);
}

best,
Oliver