Dear all,
I am trying to use reflection from C++ to, among other things, add elements
to a repeated protobuf field.
As such this works but I need to use the specific type of the data in the
repeated field. I would rather
just work with the base type Message because that allows me to write
generic code.
// This code works.
::google::protobuf::RepeatedPtrField<SpecificDerivedType>* repeated
= reflection_->MutableRepeatedPtrField<SpecificDerivedType>(
&message_, message_.GetDescriptor()->FindFieldByName(name));
Message* element = repeated->Add();
// This code segfaults in the Add call.
::google::protobuf::RepeatedPtrField<Message>* repeated
= reflection_->MutableRepeatedPtrField<Message>(
&message_, message_.GetDescriptor()->FindFieldByName(name));
Message* element = repeated->Add();
Any ideas how I can make the second code fragment work?
Have a nice day,
Chris
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.