If I have a
message Foo{
   Bar bar = 1;
}   

I can get a
Bar* bar = foo.mutable_bar();   

I'd like to be able to get, at the very least
std::weak_ptr<Bar> bar = foo.mutable_bar();   
if not a std::shared_ptr<Bar>. 

I have an issue where an object has to hold a raw pointer to a submessage, 
and it is possible to delete that submessage (using the message's API 
elsewhere), in a way that the object isn't aware of, and it attempts to use 
that stale pointer. This is one of the principle issues addressed with use 
of smart pointers, and it's unclear why protobuf cannot provide them. I 
don't understand the Arena allocation enough, if it is a problem there, but 
it seems like that would at least provide some way for weak_ptr to work. Or 
even if protobuf had its own custom template class that behaved like a weak 
pointer so that I can at least be sure I don't have stale pointers or 
references floating around in my code.



-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to