[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Automatially move from $n (was: C++11 move semantics)
From: |
Frank Heckenbach |
Subject: |
Re: Automatially move from $n (was: C++11 move semantics) |
Date: |
Sat, 15 Sep 2018 21:25:34 +0200 |
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
- Re: Automatially move from $n (was: C++11 move semantics), Akim Demaille, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Frank Heckenbach, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Hans Åberg, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Frank Heckenbach, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Hans Åberg, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics),
Frank Heckenbach <=
- Re: Automatially move from $n (was: C++11 move semantics), Hans Åberg, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Frank Heckenbach, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Hans Åberg, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Frank Heckenbach, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Hans Åberg, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Frank Heckenbach, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Hans Åberg, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Frank Heckenbach, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Hans Åberg, 2018/09/15
- Re: Automatially move from $n (was: C++11 move semantics), Frank Heckenbach, 2018/09/15