Boost logo

Boost :

From: Tim Culver (tim.gmane_at_[hidden])
Date: 2002-09-17 13:04:28


David Abrahams wrote:
> From: "Tim Culver" <tim.gmane_at_[hidden]>
>
>>Also, I think the convention above might be a good alternative. I
>>notice that the vertex descriptor does have a default constructor. My
>>question is, does a default-constructed vertex descriptor act like a
>>null value, in that it never corresponds to a valid vertex, and two
>>nulls always compare equal?
>
>
> Definitely not, and it shouldn't.
> For many graph types, vertex_descriptor is an integer type which is a
> zero-based index into the graph's vector of vertices. That's important for
> efficiency.

Now I understand! We want to be able to have descriptors without
constructors.

Still, this does not prevent writing a function that will generate a
null-like value. I think this would be a good addition to the library
for its graph datatypes.

if (vdesc == graph_traits<My_graph>::null_vertex_descriptor()) {
   // vdesc is invalid
}

Also, the particular case of adjacency_list<listS,listS,...> appears to
have actual default constructors that initialize something to zero. Can
I use these as my null generators in this particular case?

Tim Culver


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk