-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stream::write - should be implemented in terms of write(char*, int) #4
Comments
Question: What's the point of having a |
Makes no difference, we could have both methods, or just one with a generic pointer and size, but it's less secure |
Actually having a vector of widechars can be beneficial for using UTF-8/16 strings for CJK languages. |
Right but wouldn't you just use a |
I think that's problematic, the best way in my opinion is to always have utf-8 encoded strings, so either plain std::string or vector wchar_t and thus wstring shouldn't be used in public interfaces, the size of wchar_t is implementation defined. |
When I submitted this issue I wasn't talking about changing the signatures of the various overloads or whether to add or remove any, I was alluding to code duplication. Currently this is the code:
and I think it would be better written like this:
Note also that you're passing the callback by value, so it would probably be better to use perfect forwarding too:
|
@stevelorimer heh, should have caught that smell. That'd make a useful PR. |
👍 |
Duplication of code in
write
:bool write(const std::vector<char>& buf, ...)
andbool write(const std::string& buf, ...)
should just defer tobool write(const char* buf, int len, ...)
The text was updated successfully, but these errors were encountered: