First of all, this doesn't seem relevant to gRPC. I think protobuf user 
group would be the best place. (
https://groups.google.com/forum/#!forum/protobuf)
AFAIK, set_allocated_* method is for arena-usage (ref: 
https://developers.google.com/protocol-buffers/docs/reference/arenas) and 
using regular accessors would be encouraged in general.


On Wednesday, November 20, 2019 at 8:25:57 AM UTC-8, [email protected] 
wrote:
>
> What is the correct usage of StringValue in C++.
>
> google::protobuf::StringValue* test = new google::protobuf::StringValue();
> test->set_value("some string");
>
> someRequest.set_allocated_value(test);
>
> Do i have to delete the StringValue manually at the end? Why this isn't 
> possible?
> std::unique_ptr<google::protobuf::StringValue> test (new 
> google::protobuf::StringValue());
> test.get()->set_value("some string");
>
> someRequest.set_allocated_value(test.get());
>
> When i use a smartpointer i got errors when the destructor of the request 
> is called.
>
> And why there are no examples for StringValue. Also the official c++ 
> documentation of protobuf is using string instead of StringValue.
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/c430ec95-a848-4a83-9c80-fc3a6d1b4c25%40googlegroups.com.

Reply via email to