竞技场::创建和竞技场之间的区别:: createMayBemessage

发布于 2025-01-25 10:10:46 字数 215 浏览 4 评论 0原文

当我将协议缓冲区与竞技场一起使用时,这两个功能

google::protobuf::Arena::CreateMaybeMessage<LPD::MyObj>(); 

google::protobuf::Arena::CreateMessage<LPD::MyObj>();

When I using Protocol Buffer with Arena, what is the difference between those 2 functions

google::protobuf::Arena::CreateMaybeMessage<LPD::MyObj>(); 

And

google::protobuf::Arena::CreateMessage<LPD::MyObj>();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

远昼 2025-02-01 10:10:46

这很晚了,但是您的问题的答案是在文档中,在这里。消息的静态“ new()”功能使用空竞技场调用CreateMayBemessage函数。

消息*新(竞技场*竞技场):标准新方法的替代替代。它允许在给定的竞技场上创建此类型的新消息对象。如果启用竞技场分配,则其语义与Arena :: createmessage(area)相同。如果启用Arena分配的消息类型未生成,则相当于普通分配,然后是Arena-&gt; Own(消息),如果竞技场不是null。

This is pretty late, but the answer to your question is in the documentation, here. The Message's static "New()" function calls the CreateMaybeMessage function with a null Arena.

Message* New(Arena* arena): An alternate override for the standard New() method. It allows a new message object of this type to be created on the given arena. Its semantics are identical to Arena::CreateMessage(arena) if the concrete message type on which it is called is generated with arena allocation enabled. If the message type is not generated with arena allocation enabled, then it is equivalent to an ordinary allocation followed by arena->Own(message) if arena is not NULL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文