[Top][All Lists]

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

Re: C++11 move semantics

From: Hans Åberg
Subject: Re: C++11 move semantics
Date: Sun, 4 Mar 2018 15:30:17 +0100

> On 3 Mar 2018, at 22:36, Frank Heckenbach <address@hidden> wrote:
> So far my C++ parsers use the C template (which works, but with
> obvious restrictions).

Not recommended, as the compile C as C++ proved too difficult to maintain, and 
thus is not supported.

> Now I'm trying to convert them to real C++
> parsers using lalr1.cc.
> One of the main advantages I hope to achieve is to use proper C++
> classes for semantic values (where so far I've had to use manually
> managed plain pointers). However, the generated parser requires
> copyable types, just moveable isn't enough (even if I use std::move
> in all user-defined actions).

Actually not, as the default stack used std:deque, which does not invoke the 
copy constructor when reallocating.

> ... What do other
> C++11 users do in such cases?

Later Bison versions work with unique_ptr; add %require to the grammar to make 
sure one does not compile with older versions. For the untyped grammar C++ 
parser (the typed does not work properly), I found it best to use the Boehm GC 
together with a reference type. This is better than shared_ptr, which is a 
primitive form of reference counting.

reply via email to

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