When I use map<string, string> kv;
in protobuf 3.8.0, the next code works:
std::string_view key("key");
kv[key] = "value";
While in protobuf 3.19.4, the above code doesn't work.
The error msg is:
error: no match for 'operator[]' (operand types are 'google::protobuf::Map<std::__cxx11::basic_string , std::__cxx11::basic_string>' and 'std::string_view' {aka 'std::basic_string_view'})
In 3.8.0,
Map::operator[]
is declared as:Where, in your case,
Key
isstd::string
.std::string_view
is convertible tostd::string
, which is why the code works in 3.8.0.In 3.19.4,
Map::operator[]
is declared as:Where
key_arg
is declared as:And, in your case,
key_type
isstd::string
.std::string_view
is not convertible toTransparentSupport::key_arg
, which is why the code doesn't work in 3.19.4.