> On 15 Sep 2018, at 21:25, Frank Heckenbach <f.heckenb...@fh-soft.de> wrote: > > Hans Åberg wrote:
>> The idea would be to write something equivalent to >> return make_unique<foo>($1, $2, $3); >> and the Bison writes something like >> $$ = std::move(action_k(...return make_unique<foo>($1, $2, $3);...)) > > I don't follow you. What is action_k, and how would that cause > moving from $1 etc.? Action k in the switch statement. Move operators were originally designed to avoid copying in returns. >> Even in view of copy elision, default in C++17 [1], this would be safe, >> because one cannot move an already moved object by mistake. > > Why not? Because it breaks the execution path, so one cannot apply it twice to the same value. >> As the point is breaking out of the execution path, one might use your >> suggestion of a special operator in combination with an immediately >> following break in the action switch statement. So writing say >> $$$(make_unique<foo>($1, $2, $3)); >> translates into >> $$ = std::move(make_unique<foo>($1, $2, $3)); >> break; > > What if I want to write: > > $$ = make_unique <foo> ($1, $2, $3); > print ($$); Then you can't use the proposed $$$, but has to use the old syntax.