[ Web Proxy ]
URL:
Viewing: http://ja.cppreference.com/cpp/string/basic_string/begin [Back]  [Original]

std::basic_string<CharT,Traits,Allocator>::begin, std::basic_string<CharT,Traits,Allocator>::cbegin - cppreference.com
cppreference.com

std::basic_string<CharT,Traits,Allocator>::begin, std::basic_string<CharT,Traits,Allocator>::cbegin

: cppreference.com
 
C++
(C++20)
(C++20)
(C++17)
(C++11)
(C++11)
(C++11)
 
 
std::basic_string
 
<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 noexcept;
(C++11)
(C++20)
constexpr const_iterator cbegin() const noexcept;
(C++20)

begin() *this const

cbegin() const_cast<const basic_string&>(*this).begin()

()

#include <string>
#include <iostream>

int main()
{
    std::string s("Exemplar");
    *s.begin() = 'e';
    std::cout << s <<'\n';

    auto i = s.cbegin();
    std::cout << *i << '\n';
//  *i = 'E'; // error: i is a constant iterator
}

:

exemplar
e

(C++11)

() [edit]

Web Proxy Viewer  |  New URL  |  Original Page