Difference between revisions of "cpp/string/basic string/rbegin"
From cppreference.com
< cpp | string | basic string
(reverse iterator functions do not return iterator or const_iterator) |
m (Add example) |
||
Line 24: | Line 24: | ||
===Complexity=== | ===Complexity=== | ||
Constant | Constant | ||
+ | |||
+ | ===Example=== | ||
+ | {{example | ||
+ | | code= | ||
+ | #include <cassert> | ||
+ | #include <string> | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | std::string s("Exemplar!"); | ||
+ | *s.rbegin() = 'y'; | ||
+ | assert("Exemplary" == s); | ||
+ | |||
+ | auto i = s.crbegin(); | ||
+ | assert(s[s.size()-1] == *i); | ||
+ | } | ||
+ | | output= | ||
+ | }} | ||
===See also=== | ===See also=== |
Revision as of 16:28, 18 May 2014
reverse_iterator rbegin(); |
||
const_reverse_iterator rbegin() const; |
||
const_reverse_iterator crbegin() const; |
(since C++11) | |
Returns a reverse iterator to the first character of the reversed string. It corresponds to the last character of the non-reversed string.
Contents |
Parameters
(none)
Return value
reverse iterator to the first character
Complexity
Constant
Example
Run this code
#include <cassert> #include <string> int main() { std::string s("Exemplar!"); *s.rbegin() = 'y'; assert("Exemplary" == s); auto i = s.crbegin(); assert(s[s.size()-1] == *i); }
See also
(C++11) |
returns a reverse iterator to the end (public member function) |