[
https://issues.apache.org/jira/browse/THRIFT-2471?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13973885#comment-13973885
]
Randy Abernethy commented on THRIFT-2471:
-----------------------------------------
Hey Dave,
In the C++ implementation of cpp.ref did you consider shared_ptr? Not sure but
I think it might add some value over raw ptrs. The IDL below crashes with a
double delete if you ref the same object twice in the tree.
{code:title=tree.idl|borderStyle=solid}
struct tree {
1: tree left (cpp.ref="")
2: tree right (cpp.ref="")
}
service simple {
void hello(1: string msg, 2: tree t)
}
{code}
So this works:
{code:title=works.cpp|borderStyle=solid}
tree root;
root.left = new tree();
root.right = new tree();
client.hello("Hi", root);
{code}
and this doesn't:
{code:title=works.cpp|borderStyle=solid}
tree root;
tree *leg = new tree();
root.left = leg;
root.right = leg;
client.hello("Hi", root);
{code}
> Make cpp.ref annotation language agnostic
> -----------------------------------------
>
> Key: THRIFT-2471
> URL: https://issues.apache.org/jira/browse/THRIFT-2471
> Project: Thrift
> Issue Type: Improvement
> Components: Compiler (General)
> Reporter: Jens Geyer
>
> The proposal is to make the new {{cpp.ref}} annotation introduced with
> THRIFT-2421 language agnostic instead of a C++ specialty only.
> The annotation changes inlined nested structs into pointers to structs. This
> behaviour is potentially relevant with all languages using value semantics
> for nested structs etc.
--
This message was sent by Atlassian JIRA
(v6.2#6252)