std::basic_string<CharT,Traits,Allocator>::begin, std::basic_string<CharT,Traits,Allocator>::cbegin
cppreference.com
<tbody>
</tbody>
<tbody class="t-dcl-rev t-dcl-rev-num ">
</tbody><tbody>
</tbody>
<tbody class="t-dcl-rev t-dcl-rev-num ">
</tbody><tbody>
</tbody>
<tbody class="t-dcl-rev t-dcl-rev-num ">
</tbody><tbody>
</tbody>
| (1) | ||
iterator begin(); |
( C++11) | |
iterator begin() noexcept; |
( C++11) ( C++20) |
|
constexpr iterator begin() noexcept; |
( C++20) | |
| (2) | ||
const_iterator begin() const; |
( C++11) | |
const_iterator begin() const noexcept; |
( C++11) ( C++20) |
|
constexpr const_iterator begin() const noexcept; |
( C++20) | |
| (3) | ||
const_iterator cbegin() const; |
( C++11) | |
const_iterator cbegin() const noexcept; |
( C++11) ( C++20) |
|
constexpr const_iterator cbegin() const noexcept; |
( C++20) | |
.
begin() mutable , *this.
cbegin() . const_cast<const basic_string&>(*this).begin().
()
.
.
#include <iostream>
#include <string>
int main()
{
std::string s("Exemplar");
*s.begin() = 'e';
std::cout << s << '\n';
auto i = s.cbegin();
std::cout << *i << '\n';
// *i = 'E'; // : i
}
:
exemplar
e
C++:
| LWG 1192 | C++98 | std::basic_string - cbegin()
|
(DR*) |
(public -) |
(C++17) |
(public - std::basic_string_view<CharT,Traits>)
|