
Rob Stewart <stewart@sig.com> writes:
From: David Abrahams <dave@boost-consulting.com>
David Abrahams <dave@boost-consulting.com> writes:
and the example taking a non-const reference is confusing. I'll shuffle things around.
Done.
Much better.
On the other hand\x{2014}as you may recall from the parameter table\x{2014}``color_map`` is an \x{201C}out\x{201D} parameter, so it really should be passed by non-const reference.
Note that "color_map" and "out" are quoted significantly differently with no apparent reason.
No, ``color_map`` isn't quotation; it's markup for "code font." Look at the HTML.
A keyword object has a pair of operator= overloads that ensure we can pass anything by name, but when an \x{201C}out\x{201D} parameter is passed positionally, that's no help: in this case, core::depth_first_search would end up with a const reference to the color_map and compilation will fail when mutating operations are used on it.
That's a long sentence and did you really mean to say "we can pass *anything*" (emphasis mine)?
Yep.
Perhaps this would be better:
A keyword object has a pair of operator = overloads that ensure we can pass references to const or non-const objects by name,
You don't get to pass references to anything in C++. You pass the object referred to by a name or expression and the callee decides whether it goes by reference. Also, the point is that you can pass both lvalues and rvalues, or temporaries and non-temporaries, not that the objects can be const or non-const. You can do that just fine with a single templated function taking a T& (T will be deduced as U const when the object is constant).
but when an "out" parameter is passed positionally, that's no help. In that case, core:;depth_first_search would end up with a...."
-- Dave Abrahams Boost Consulting www.boost-consulting.com