Hans Åberg wrote: > >> One idea might be to wrap the actions in inlines, and use return instead, > >> as C++ can recognize r-values in such situations. > > > > I think we discussed this before, but this would only cover the case > > "$$ = $N" (which is covered by the default action for N = 1 anyway). > > > > More interesting are cases such as: > > > > $$ = make_unique <foo> ($1, $2, $3); > > 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.? > 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? > 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 ($$); Regards, Frank
