HI Another dummy question:
How to I express exp: Exp1 "OR" Exp | Exp1 in class if I do not use pointer? I mean class Exp is just a pure interface class? class Exp { } class Elor : public Exp { public: Exp exp_1; // if not a pointer? Exp exp_2; // if not a pointer ~Elor() {} } Thanks. min On Thu, Aug 18, 2016 at 3:07 PM, Min Wang <mingew...@gmail.com> wrote: > Hi > > @Hans, thanks a lot! > > Could you explain more on "reference count" ? do you mean > std::shared_ptr? > > > > min > > > On Thu, Aug 18, 2016 at 12:21 PM, Hans Åberg <haber...@telia.com> wrote: > >> >> > On 18 Aug 2016, at 18:07, Min Wang <mingew...@gmail.com> wrote: >> >> > (1) when ListExp was returned up to PROG (e.g: PROG($1)), does it use >> copy >> > constructor? or >> > use move constructor if it existed? >> >> A part from translation of the $-variables, the action code is copied >> verbatim to the C++ parser. So do not think move constructors are invoked, >> since that happens in special syntactic context where it is known that a >> variable will perish. >> >> > (2) should I use object ( ListExp) inside PROG class or a >> > std::unique_ptr inside the PROG to save some copy ? In the latter case, >> > how can I initial std::unique_ptr if the passed parameters if a obj? >> >> Don’t use that, because in some cases there may be an implicit $$ = $1, >> which might make it obsolete. Instead use a reference count or a GC, like >> the Hans Boehm one: >> http://www.hboehm.info/gc/ >> >> >> > > > -- > http://www.comrite.com > > > > -- http://www.comrite.com _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison