[BGL] why not breakup put_get_helper into three structs?
Helllo,
I was wondering why put_get_helper shouldn't be three structs (put_helper,
get_helper, put_get_helper, with the latter deriving from from the formers)
instead of one? My rationale is outlined below along with the proposed code.
//Begin Rationale
Problem: want a helper method for readable property maps.
Solution1: use exist boost::put_get_helper and just never use the put
function.
Problem with solution 1:
1) the put function will still be "callable", and
2) calling the put function will result in an invalid assignment to a
read-only variable compiler error, which is cryptic to decipher, ie, that
even though the put function does exist it should not be called. The
only way to clarify this would be via documentation, which then brings
about the problem of keeping code in sync with comments.
Solution2: make a helper method for readable property maps
that won't make the put companion function a valid function call,
ie, break up boost::put_get_helper to put_helper, get_helper, and
put_get_helper which derives from the latter two.
Problems with solution 2: None that I can see.
Advantages of solution 2:
1) It's self-documenting whether the put or get functions are intended
to be called, ie if I derive from get_helper then it's self-evident
that I shouldn't be calling the put function (vice versa); and
2) given the above scenario, even if by chance the put function get's called
the compiler error message will be easier to decipher, ie, something along the
lines of:
participants (1)
-
Mostafa