Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-12-06 18:52:16


On Saturday 06 December 2003 02:59 pm, Ronald Garcia wrote:
> Douglas Gregor wrote:
> >On Saturday 06 December 2003 11:32 am, garcia wrote:
> >>Douglas Gregor wrote:
> >>>Would anyone object if I made property maps into function objects? Any
> >>>downsides?
> >>
> >>Are you suggesting changing the interface specified by the concepts in
> >>the property map library, specifically, the LValuePropertyMap?
> >
> >Yep. Essentially adding pmap(key) as a synonym for pmap[key]. Granted, I'd
> >like pmap(key) to return an lvalue for an lvalue property map, a
> >convertible-to-T for a readable property map, and an assignable-from-T
> > from a writable property map, just so it can be consistently used.
>
> Got it. I don't think that's a good idea. My reasoning is this: The
> property-map interface allows for a great deal of flexibility in the
> implementation of property maps. That is, a model of the Readable (or
> Writeable) Property Map concepts need not provide any member functions.
>
> This is important especially when adapting a non-BGL graph type to
> use BGL algorithms (take it from one who's been there ;) ). Under those
> circumstances, it is very *good* to be able to construct a property map
> interface by simply adding traits classes and overloads of put() and/or
> get().

Ah ha! That's the rationale I was missing. Thank you.

> I guess I could almost see adding operator() to LValuePropertyMap, but
> then the property-map-as-function-object idiom would only work for that
> special case of property map.

That special case does seem to cover the vast majority of property maps. At
least, I've seen/written very few property maps that aren't lvalue property
maps. Aside from the fact that lvalue property maps already supported
operator[], is there any reason to prefer operator[] to operator()?

> So, given these issues, I think that it would be better to provide a
> means to easily wrap property maps into a function objects.

This would surely be a useful adaptor, but I'd of course be happier if I
didn't have use an adaptor.

        Doug


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