std::basic_string<CharT,Traits,Allocator>::front
: cppreference.com
<tbody>
</tbody>
<tbody class="t-dcl-rev ">
</tbody><tbody>
</tbody>
<tbody class="t-dcl-rev ">
</tbody><tbody>
</tbody>
CharT& front(); |
(C++11) (C++20) |
|
constexpr CharT& front(); |
(C++20) | |
const CharT& front() const; |
(C++11) (C++20) |
|
constexpr const CharT& front() const; |
(C++20) | |
empty() == true
()
operator[](0)
Run this code
#include <iostream>
#include <string>
int main()
{
{
std::string s("Exemplary");
char& f = s.front();
f = 'e';
std::cout << s << '\n'; // "exemplary"
}
{
std::string const c("Exemplary");
char const& f = c.front();
std::cout << &f << '\n'; // "Exemplary"
}
}
:
exemplary
Exemplary
(C++11) |
() |