Comment #7 on issue 336 by [email protected]: Support generic string
type
http://code.google.com/p/protobuf/issues/detail?id=336
assuming you refer to the '1 2 3' question in comment 3:
std::wstring also supports this kind of contract, it has data() and size()
methods,
however passing a wstring to the proposed methods will merely cause a
compile time warning, but may cause severe run-time issues, as the
wchar_t's in the wstring will be truncated to chars, hence causing data
loss, or even worth corruption (the resulting string may not be utf8
compatible as proto requires).
so yes, I do see some possible damage in adding this kind of overloads.
however if you do have classes that can be safely transformed into a string
(requiring more than one-liner as you stated before) you have several
options:
1. write a utility method to do this for you.
2. generate the setters for your specific classes using a plug-in.
either way you choose, I wouldn't recommend using function templates for
this, as it may introduce some dangers like the example I gave above, and
in any case I don't think the maintainers of GPB can support you on this
one as they are not aware of your classes and as I said this kind of
function template introduce some danger (and as the maintainer answered
you, some complexity).
eyal.
--
You received this message because you are subscribed to the Google Groups "Protocol
Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.