Edward Diener writes:
 >I know that I am missing how the mechanism works which links
 > the property_map concept to the get(), put(), and operator[] functions.

A property map is something which relates "keys" to "values", where there "keys"
are the "names" of the properties. Given a property map, you can get and/or
set the "value" associated with each "key" using the get() and put()
functions.

You can build a property map out of anything at all, just by defining the
necessary interface. For example, you could build a property map that returned
the values of class members by name, or one that returned the n-th number in a
mathematical sequence, given n.

The idea is that in your generic code, you say "give me a property map which I
can use with the following keys to return values of type T", and it is then up
to the client code how they implement that property map --- _anything_ which
provides the necessary interface will do.

operator[] is essentially just syntactic sugar for get()/put(), where the
values are real, discernable objects, for which you can obtain a
reference. Returning a reference means that you can store the reference for
later use, or pass it to another function, and is actually the key benefit of
using operator[] rather than plain get()/put().

Anthony
-- 
Anthony Williams
Senior Software Engineer, Beran Instruments Ltd.
Remove NOSPAM when replying, for timely response.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to