A better solution should be to refactor your code a little bit to pass in a
mutable string object directly. You can expect protos to take movable
objects in the future, but even when that happens you will still need to
refactor your code.
I don't think we will change protobuf to share references to const objects,
nor will protobuf support shared_ptr stuff.


On Thu, Mar 14, 2013 at 6:17 PM, Kevin Regan <kevin.d.re...@gmail.com>wrote:

> Giving this a bump.  This might also be considered a feature request (the
> ability to temporarily assign a string value to a protocol buffer during
> serialization, rather than copying it).
>
> --Kevin
>
>
> On Friday, March 8, 2013 1:49:29 PM UTC-8, Kevin Regan wrote:
>>
>> I often have situations like this:
>>
>> void do_something(const std::string& value)
>> {
>>        my_proto_buffer.set_value(**value);
>>        // serialize my_proto_buffer to a stream
>> }
>>
>> Would it be valid to do this:
>>
>> void do_something(const std::string& value)
>> {
>>        my_proto_buffer.set_allocated_**value(&((std::string&)value));
>>        try {
>>            // serialize my_proto_buffer to a stream
>>        }
>>        catch (...) {
>>             my_proto_buffer.release_value(**)
>>             throw;
>>        }
>>        my_proto_buffer.release_value(**);
>> }
>>
>> or can I not rely on the internal string not being modified during
>> serialization?
>>
>> Thanks,
>> Kevin
>>
>>  --
> 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 http://groups.google.com/group/protobuf?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to