-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
class String constant opeator [] should return const reference! #48
Comments
You have created a pointer to a char obkect and then tryed to access to its
|
ye i know what i was doing. what i mean, look at the c++ stl string or other string implement, almost of them return a const reference but a temp object ! in my opinion it is UNREASONABLE ! |
Like it not, the String class API supports writing to the string with array syntax. It's had this feature since the first release in Arduino 0019, so there's probably no way the Arduino Team will remove that feature now. String supports this syntax: String str = "test"; When the user writes this: str[10] = 'x'; what do you believe String should do? Going back in time to before Arduino 0019 to remove writable array syntax is probably not an option. |
I think I'm with @qinqingege on this one. This is not about removing the
but not
? This would be solved by just replacing the current |
@cousteaulecommandant thanks for summarizing the needed change. It looks like a good and consistent change to me. |
commonly people want get the buffer ptr by a constant String object like below:
const String &str;
const char *p = &str[0];
BUT now the constant operator [] returns a temp char object, i don't think it is better.
The text was updated successfully, but these errors were encountered: