Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-04-15 08:19:45


Thorsten Ottosen wrote:

>> Currently, to initialize all properties one has to do:
>>
>> edge_descriptor e = add_edge(....);
>> put(e, g, vertex_color, 10);
>> put(e, g, vertex_name, "foo");
>>
>> I hope that with the named parameters library it will be possible to do:
>>
>> add_edge(v1, v2, (vertex_color = 10, vertex_name = "foo"), g);
>
> FWIW, I could try and see if it will be possible to use the assign lib to
> write something like
>
> assign::add_egde( v1, v2, g )(vertex_color,10)(vertex_name, "foo" );

It could be possible too. Though I have some preference to named params
library. The reason is the notion of container which has types as indices
but returns real values when subscribed. I've played with this idea in
past, and I also see this approach used for filesystem attributes (in the
sandbox).

I'm pretty sure named params library implements such a container internally,
and if it's exposed/documented it probably can even replace
boost::property.

Consider another thing that was around for a while: associative_list. That's
map from type to type. Combined with map from type to value this can be use
in BGL like this:

    template<...., class VertexProperty, ... >
    class graph {
        typedef type2value_map<VertexProperty> vertex_property;
    };

    typedef graph<....,
        make_type_2_type_map(vertex_color_t, unsigned,
                             vertex_name_t, std::string,
                             vertex_weight_t, unsigned) ... > my_graph;

I think this might simplify some of the BGL internals. And for another
example, if named parameters produce documented class type2value_map, we
can do this:

   depth_first_visit(..,
        (on_vertex_discover = cout << constant("found vertex") << _1,
         on_back_edge = ....));

And probably in some other places. If we use the same classes everywhere,
the implementation will be simplified.

- Volodya

                                            


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