bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatially move from $n (was: C++11 move semantics)


From: Hans Åberg
Subject: Re: Automatially move from $n (was: C++11 move semantics)
Date: Sun, 1 Apr 2018 20:24:35 +0200

> On 1 Apr 2018, at 19:23, Frank Heckenbach <address@hidden> wrote:
> 
> Hans Åberg wrote:
> 
>>> On 1 Apr 2018, at 16:43, Frank Heckenbach <address@hidden> wrote:
>>> 
>>> As expected, they now contain a lot of "std::move ($n)" expressions.
>>> Even though the simple case "$$ = std::move ($1)" is now covered by
>>> the default action, most are actually within expressions such as
>>> "$$ = make_foo (std::move ($1), std::move ($2))" which is less than
>>> perfectly readable ...
>> 
>> Maybe Bison might support some additional symbol for move action values, 
>> like $$k.
> 
> I'd thought about this, but it would require changes to Bison itself
> (for a rather special feature, only for only target language, which
> can be done in the skeletons), and the user grammar files would also
> look differently, whereas with my way, they generally look just like
> they would with shared pointers, or in C, Java, etc., i.e.
> "$$ = make_foo ($1, $2)".
> 
> Also "$$k" would look rather similar to "$$" (probably not strictly
> a conflict, but maybe confusing).

Maybe just add to %code:
  semantic_type&& operator*(semantic_type& x) { return std::move(x); }
and use *$k, in case this operator is not needed for something else.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]