Skip to content

Commit 0489fe3

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 5e194bd commit 0489fe3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cores/arduino/WString.h

Lines changed: 2 additions & 0 deletions
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)