Namespaces
Variants

std::basic_string<CharT,Traits,Allocator>::rend, std::basic_string<CharT,Traits,Allocator>::crend

출처: ko.cppreference.net
 
 
 
std::basic_string
 
reverse_iterator rend();
(1) (C++11부터 noexcept)
(C++20부터 constexpr)
const_reverse_iterator rend() const;
(2) (C++11부터 noexcept)
(C++20부터 constexpr)
const_reverse_iterator crend() const noexcept;
(3) (C++11부터)
(C++20부터 constexpr)

뒤집힌 문자열의 마지막 문자 다음 문자를 가리키는 역방향 반복자를 반환합니다. 이는 뒤집히지 않은 문자열의 첫 번째 문자 앞 문자에 해당합니다. 이 문자는 자리 표시자 역할을 하며, 접근을 시도하면 정의되지 않은 동작이 발생합니다.

매개변수

(없음)

반환값

마지막 문자 다음에 오는 문자로의 역방향 반복자.

복잡도

상수.

참고 사항

libc++ 백포트가 crend() 를 C++98 모드로 이전합니다.

예제

#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
int main()
{
    std::string p("[A man, a plan, a canal: Panama]");
    std::string q;
    std::copy(p.crbegin(), p.crend(), std::back_inserter(q));
    std::cout << "q = " << q << '\n';
    std::copy(q.crbegin(), q.crend(), p.rbegin());
    std::cout << "p = " << p << '\n';
}

출력:

q = ]amanaP :lanac a ,nalp a ,nam A[
p = ]amanaP :lanac a ,nalp a ,nam A[

참고 항목

시작 부분으로의 역방향 반복자를 반환합니다
(public member function)
끝 부분으로의 역방향 반복자를 반환합니다
( std::basic_string_view<CharT,Traits> 의 public member function)