|
Boost : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-04-15 05:56:46
I've just made an attempt to use the named parameters library (currently in
review queue, and available at
http://groups.yahoo.com/group/boost/files/named_params.zip) to simply
properties in BGL.
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);
I've tried to implement this idea, but run into the problems. First issue is
documentation: it gives
foo_impl(foo_keywords(a0));
as example, while the code uses:
return f_impl(f_keywords()(t, name_));
Which has extra '()' after f_keywords.
The second problem is that I need to create a type for 'keywords' (derived
from 'keywords<...>' and use it for passing arguments). The docs suggest to
create a number of forwarding functions, but given that a number of vertex
properties can be rather large (and is actually unbounded), this does not
seem good.
So, now can do:
vertex_property p = prop_keywords()(color = 10, name = "foo");
but I'd rather like:
vertex_property p((color = 10, name = "foo"));
So, the operator, will be overloaded to create something I can index with 'tag
type' and get a value. In fact, this will allow to avoid declaring
'pop_keywords' -- since again, user can declare it's own keywords so it's not
clear how to define that class.
The example I've played with is at:
http://zigzag.cs.msu.su:7813/p.cpp
Comments are appreciated.
- Volodya
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk