Skip to content

Commit 8e385bf

Browse files
Chris--Acmaglie
authored andcommitted
Updated String library to use C++11 iterators.
This will allow using the String library in a ranged for loop: ```C++ String s = "Hi, this is a test"; for( char c : s ) Serial.print( c ); ```
1 parent 2ddbf01 commit 8e385bf

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: hardware/arduino/avr/cores/arduino/WString.h

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ class String
8989
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
9090
String & operator = (String &&rval);
9191
String & operator = (StringSumHelper &&rval);
92+
auto begin() -> const char* { return c_str(); }
93+
auto end() -> const char* { return c_str() + length(); }
9294
#endif
9395

9496
// concatenate (works w/ built-in types)

0 commit comments

Comments
 (0)