[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: About %destructor is c++ mode
From: |
Min Wang |
Subject: |
Re: About %destructor is c++ mode |
Date: |
Thu, 18 Aug 2016 12:07:44 -0400 |
Hi
@hans. thanks!
Let's say I change to use c++ obj instead of pointer
e.g:
%type <PROG> PROG
%type <ListExp> ListExp
PROG : ListExp driver.store_ast( PROG($1) );
ListExp : Exp { $$ = ListExp(); $$.push_back($1)); }
Exp : Exp "OR" Exp1 { $$ = Elor($1, $3) ; }
using ListExp_PTR = std::unique_ptr<ListExp>;
class PROG
{
public:
// should I use obj here?
// ListExp listexp_;
// or pointer?
ListExp_PTR listexp_;
...
}
My some dummy questions are:
(1) when ListExp was returned up to PROG (e.g: PROG($1)), does it use copy
constructor? or
use move constructor if it existed?
(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?
thanks
min
On Thu, Aug 18, 2016 at 11:45 AM, Hans Åberg <address@hidden> wrote:
>
> > On 18 Aug 2016, at 16:03, Min Wang <address@hidden> wrote:
>
> > So I should use
> >
> > %type <PROG> PROG
> >
> > instead of
> >
> > %type <PROG*> PROG
>
> > Thus I do not need %destructor at all?
>
> If you write a proper C++ type T with T::~T destructor, then %destructor
> should not be used, nor explicit deallocation in the actions.
>
>
--
http://www.comrite.com
- About %destructor is c++ mode, Min Wang, 2016/08/18
- Re: About %destructor is c++ mode, Hans Åberg, 2016/08/18
- Re: About %destructor is c++ mode, Min Wang, 2016/08/18
- Re: About %destructor is c++ mode, Hans Åberg, 2016/08/18
- Re: About %destructor is c++ mode, Min Wang, 2016/08/18
- Re: About %destructor is c++ mode, Hans Åberg, 2016/08/18
- Re: About %destructor is c++ mode, Min Wang, 2016/08/18
- Re: About %destructor is c++ mode, Hans Åberg, 2016/08/18
- Re: About %destructor is c++ mode,
Min Wang <=
- Re: About %destructor is c++ mode, Hans Åberg, 2016/08/18
- Re: About %destructor is c++ mode, Min Wang, 2016/08/18
- Re: About %destructor is c++ mode, Min Wang, 2016/08/18
- Re: About %destructor is c++ mode, Hans Åberg, 2016/08/18
- Re: About %destructor is c++ mode, Min Wang, 2016/08/18
- Re: About %destructor is c++ mode, Hans Åberg, 2016/08/19
- Re: About %destructor is c++ mode, Min Wang, 2016/08/19
- Re: About %destructor is c++ mode, Hans Åberg, 2016/08/19
- Re: About %destructor is c++ mode, Min Wang, 2016/08/19
- Re: About %destructor is c++ mode, Hans Åberg, 2016/08/19