the original construction works only as long as we stick to the "classical" Builder syntax, i.e. use chained calls of the builder functions. But as soon as we just invoke some builder function for sake of the side-effect on the data within the builder, this data is destroyed and moved out into the value return type, which unfortunately is being thrown away right afterwards. Thus: either make a builder really sideeffect-free, i.e. do each mutation on a new copy (which is kind of inefficient and counterfeits the whole idea) or just accept the side-effect and return only a reference. In this case, we can still return a rvalue-Reference, since at the end we want to move the product of the build process out into the destination. This works only due to the C++ concept of sequence points, which ensures the original object stays alive during the whole evaluation of such a chained builder expression. NOTE: the TreeMutator (in namespace lib::diff) also uses a similar Builder construction, but in *that* case we really build a new product in each step and thus *must* return a value object, otherwise the reference would already be dangling the moment we leave the builder function. |
||
|---|---|---|
| .. | ||
| draw | ||
| DIR_INFO | ||
| empty.html | ||
| InterfaceConcept_Varga.mm | ||
| renderengine.html | ||
| thinkPad.ichthyo.mm | ||
| uml | ||
| workflow.mm | ||