std::basic_string<CharT,Traits,Allocator>::front
From cppreference.com
CharT& front(); |
(since C++11) | |
const CharT& front() const; |
(since C++11) | |
Returns reference to the first character in the string.
Contents |
Parameters
(none)
Return value
reference to the first character.
Complexity
Constant
Notes
front
requires that !empty() == true, otherwise the result is undefined.
Example
Run this code
#include <cassert> #include <string> int main() { { std::string s("Exemplary"); char& f = s.front(); f = 'e'; assert("exemplary" == s); } { std::string const c("Exemplary"); char const& f = c.front(); assert('E' == f); } }
See also
(DR*) |
accesses the last character (public member function) |