zangw
zangw

Reputation: 48456

Error: 2 overloads have no legal conversion for this pointer, when protocol buffer method is invoked

Could someone help me figure this error C2663: MediaSetting::mutable_mediamessage: 2 overloads have no legal conversion for this pointer happened, when mutable_mediamessage() is called in the following codes.

class MediaSetting : public ::google::protobuf::Message {
 public:
  inline ::MSG::MediaMessage* mutable_mediamessage(int index);
  inline ::google::protobuf::RepeatedPtrField< ::MSG::MediaMessage >* mutable_mediamessage();
}

inline ::MSG::MediaMessage* MediaSetting::mutable_mediamessage(int index) {
  return mediamessage_.Mutable(index);
}

inline ::google::protobuf::RepeatedPtrField< ::MSG::MediaMessage >*
MediaSetting::mutable_mediamessage() {
  return &mediamessage_;
}

// my test codes
// ...
const ::MSG::MediaSetting& media = config.mediasetting();
::google::protobuf::RepeatedPtrField<::MSG::MediaMessage>* pmedia = media.mutable_mediamessage(); // Error C2663 is here

Environment: VS2008

Upvotes: 0

Views: 774

Answers (1)

marom
marom

Reputation: 5230

You are attempting to access a non-const member function via a const reference.

Upvotes: 1

Related Questions