[xsd-users] C++ 11 move semantics

Ovanes Markarian om_codesynthesis at keywallet.com
Thu Jun 27 08:25:01 EDT 2013


On Thu, Jun 27, 2013 at 2:06 PM, Boris Kolpackov <boris at codesynthesis.com>wrote:

> Hi Ovanes,
>
> Please don't post multiple copies of the same. If you sent it from an
> unsubscribed address, just wait for it to go through moderation.
>
Oh, sorry. Did not know, how the mailing list is configured, some just
automatically refuse such emails.


>
>
> Ovanes Markarian <om_codesynthesis at keywallet.com> writes:
>
> > The base parser skeleton has the following construct:
> >
> >                 std::unique_ptr<what_ever_type> tmp
> > (this->Underlying_parser_->post_WhatEverType());
> >                 this->WhatEverType (tmp);
> >
> > Here I need to either use an explicit move: std::move(tmp) or pass the
> > r-value to the WhatEverType function:
> >
> >                 std::unique_ptr<what_ever_type> tmp
> > (this->Underlying_parser_->post_WhatEverType());
> >                 this->WhatEverType (std::move(tmp));
> >
> > or
> >
> > this->WhatEverType(this->Underlying_parser_->post_WhatEverType())
> >
> >
> > Is there any work around for that?
>
> A few that I see:
>
>   1. Accept the pointer in WhatEverType() as an l-value reference. Inside
>      you can call std::move() yourself.
>
>   2. Use shared_ptr.
>
>
> > Can I specify in a type-map file a move function to be used.
>
> No, this is not currently supported.
>
> Boris
>

Ok, I just did some dirty hack and modified the generated code. Otherwise,
it is not descriptive that the ownership is transferred and I also don't
want to have some shared state, as some people, who are going to maintain
my code might come to the idea to store such a pointer... IMO, hacking the
generated code is the best alternative, as it breaks the newly generated
code and forces the developer to understand the impact, instead of
accepting smth silently and transferring the ownership it in an non-obvious
way. Do you plan to solve that issue in an upcoming release? Are there any
plans for the upcoming release?


Thanks for your help,
Ovanes


More information about the xsd-users mailing list