[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 22:10:12 +0200 |
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.
> >
> > Huh? I really don't get what your proposed syntax is supposed to
> > mean. Is action_k supposed to be a lambda (what else could appear in
> > an expression and contain a statement inside)? What would it do?
>
> Just produce an r-value.
Again:
- make_unique already produces an rvalue
- (I'll ignore the "...return", since you didn't comment on it, I
assume it's a typo)
- Then, you say, action_k produces an rvalue, from an rvalue?
- Finally, std::move takes this rvalue and turns it into an rvalue
(because that's what std::move does).
Do you want a triple-r-value?
Sorry if I'm a bit cynical meanwhile, but I said I don't follow what
you intend to do, so it would be nice to explain it with something
more than half a sentence, really.
> >> Move operators were originally designed to avoid copying in returns.
> >
> > I don't know if this was so or not originally, but I'm talking about
> > moving arguments, not return values. That's what I've been saying
> > the whole time, including the thread subject! Moving the return
> > value is no big problem most of the time: "$$ = make_unique ..."
> > works without any std::move because a function result(*) is
> > automatically an rvalue.
>
> The idea is to create an r-value situation, which then translates into a move
> assignment.
Again, make_unique already "creates an rvalue situation".
And, also again, how does any of that help with moving from $1, $2
etc. which is the actual topic?
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, 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/16