L'ajout d'un Protocole de Tampons répété champ

Je travaille en C++ avec un Tampon Protocole de modèle, y compris le message suivant:

message StringTable {
   repeated bytes s = 1;
}

Je suis d'essayer d'ajouter une nouvelle valeur aux données existantes, comme suit:

pb.stringtable().s().Add(replace_key);

Toutefois, cela génère une erreur à la compilation (à l'aide de clang sur OS X):

test.cpp:51:4: error: member function 'Add' not viable: 'this' argument 
  has type 'const ::google::protobuf::RepeatedPtrField< ::std::string>', 
  but function is not marked const
                    pb.stringtable().s().Add(replace_key);
                    ^~~~~~~~~~~~~~~~~~~~

Des indices? Je suis très en C++ newbie donc peut-être faire une stupide erreur.


Edit:

À l'aide de la accesseurs produit une erreur similaire:

pb.stringtable().add_s(replace_key);

résultats dans:

test.cpp:51:21: error: no matching member function for call to 'add_s'
                        pb.stringtable().add_s(replace_key);
                        ~~~~~~~~~~~~~~~~~^~~~~
./osmformat.pb.h:3046:26: note: candidate function not viable: 'this' argument has type 'const ::StringTable', but method is not marked const
inline void StringTable::add_s(const ::std::string& value) {
                     ^
./osmformat.pb.h:3050:26: note: candidate function not viable: 'this' argument has type 'const ::StringTable', but method is not marked const
inline void StringTable::add_s(const char* value) {
                     ^
./osmformat.pb.h:3043:36: note: candidate function not viable: requires 0 arguments, but 1 was provided
inline ::std::string* StringTable::add_s() {
                               ^
./osmformat.pb.h:3054:26: note: candidate function not viable: requires 2 arguments, but 1 was provided
inline void StringTable::add_s(const void* value, size_t size) {

OriginalL'auteur Richard Fairhurst | 2015-01-02