Boost logo

Boost Users :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2005-03-18 14:22:20


On Mar 18, 2005, at 1:53 AM, S wrote:
> Here is a situation where typedefs for EdgeList etc can prove to be
> very useful.
>
> template < class graph_type >
> void foo( graph_type& g )
> {
> // I would like to create another graph type which depends
> // on the value of the template parameter graph_type
> // e.g.
>
> typedef adjacency_list< graph_type::EdgeList,
> graph_type::VertexList,
> undirectedS
>> another_graph_type;
> // note that graph_type could have been directedS or bidirectionalS
> // but I would like to ignore that when creating another_graph_type
>
> another_graph_type ag;
> copy_graph( g, ag );
> // and so we have an undirected version of the input graph - g
> }

To be really picky, since "graph_type" has to be an adjacency list
anyway, one possibility is to do this:

template<typename OutEdgeListS, typename VertexListS, typename
DirectedS,
                   typename VertexProperty, typename EdgeProperty,
typename EdgeListS>
void foo(adjacency_list<OutEdgeListS, VertexListS, DirectedS,
VertexProperty, EdgeProperty, EdgeListS>& g)
{
   // ...
}

It is a bit verbose, but in a sense it is more "correct" because it
more accurately reflects the parameter type.

> What do you think?

I had originally thought you wanted something different. I'm not at all
opposed to providing these typedefs. I'm just about to check in changes
that provide the typedefs out_edge_list_selector, vertex_list_selector,
directed_selector, and edge_list_selector for the OutEdgeListS,
VertexListS, DirectedS, and EdgeListS template parameters,
respectively.

        Doug


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