
From: David Abrahams <dave@boost-consulting.com>
Rob Stewart <stewart@sig.com> writes:
From: David Abrahams <dave@boost-consulting.com>
I didn't look, but it sounded odd that one could pass an int,> char *, std::complex, etc.
Well, you can at least pass anything to the keyword's operator=.Whether or not the depth_first_search function compiles is anothermatter.
OK.
Pedantry aside, what else is there?
I suppose there are two levels of pedantry in this case. One is in the tutorial itself, and the other was due to my talking about passing references.
How's this? A keyword object has a pair of ``operator=`` overloads that ensure we can pass anything—temporary or not, ``const`` or not—by name, while preserving the mutability of non-temporaries: .. parsed-literal:: template <class A> // handles non-const, |ArgumentPack| operator=(A&); // non-temporary objects template <class A> // handles const objects |ArgumentPack| operator=(A const&); // and temporaries However, when an “out” parameter is passed positionally, there's no keyword object involved. With our ``depth_first_search`` overload set above, the ``color_map`` will be passed by ``const`` reference, and compilation will fail when mutating operations are used on it. The simple solution is to add another overload that takes a non-``const`` reference in the position of the “out” parameter:
That should do it! -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;