|
Boost Users : |
From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2007-05-30 12:45:17
Filip Konvi?ka ha escrito:
[...]
> This is OK, but first I need to get the node "n", which seems hard. This
> is because it is the "member" field of the container, which must be
> accessed via some down-cast to header_holder<T1, Tx>, and Tx depends on
> T2, but I can not derive Tx from T2 in the visualizer (I could use some
> typedefs from multi_index::detail to get Tx, but this is not supported
> by the debugger).
>
> Specifically, given the multi_index_container<*,indexed_by<*>,*> >
> pattern, I need to cast the container variable to
>
> header_holder<sequenced_index_node<Q2> >,
> multi_index_container<T1,indexed_by<T2>,T3> >,
>
> where Q2 is something like
> sequenced_index_node<hashed_index_node<index_node_base<T1> > >, which I
> don't know how to construct from T2.
OK, I think I begin to understand the limitations of the visualizer with
respect to type calculation. I think you can circumvent this problem by exercising
some hacks similar in spirit to your VISUALIZE_MULTI_INDEX_CONTAINER
thing -but less intrusive. Define the following:
template<typename Value,typename IndexSpecifierList,typename Allocator>
struct header_holder_accessor:
private ::boost::base_from_member<
typename boost::detail::allocator::rebind_to<
Allocator,
typename boost::multi_index::detail::multi_index_node_type<
Value,IndexSpecifierList,Allocator>::type
>::type>
{
typedef typename boost::multi_index::detail::multi_index_node_type<
Value,IndexSpecifierList,Allocator>::type node_type;
node_type* value;
};
Now you can do the following cast in your visualizer:
multi_index_container<T1,T2,T3>* --> header_holder_accessor<T1,T2,T3>*
and you get to the header_holder part by applying ".value". Now you can
move the rest of the work to a header_holder<Q1,Q2> visualizer.
Similarly, if you define
template<typename Super>
struct sequenced_index_node_value_accessor
{
typedef typename Super::value_type value_type;
value_type value;
};
when you're in the sequenced_index_node<T1> visualizer you can do the
following cast
sequenced_index_node<T1>* --> sequenced_index_node_value_accessor<T1>*
and get to the value by applying ".value", which automagically has the right
type. Does this help work around the limitations of the visualizer?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net