Namespaces
Variants

std::multiset<Key,Compare,Allocator>:: end, std::multiset<Key,Compare,Allocator>:: cend

From cppreference.net

iterator end ( ) ;
(1) (C++11부터 noexcept)
(C++26부터 constexpr)
const_iterator end ( ) const ;
(2) (C++11부터 noexcept)
(C++26부터 constexpr)
const_iterator cend ( ) const noexcept ;
(3) (C++11부터)
(C++26부터 constexpr)

* this 의 마지막 요소 바로 다음을 가리키는 반복자를 반환합니다.

이 반환된 반복자는 단지 센티넬 역할만 합니다. 이것이 dereferenceable 하다는 보장은 없습니다.

range-begin-end.svg

목차

반환값

마지막 요소의 다음을 가리키는 반복자.

복잡도

상수.

참고 사항

iterator const_iterator 모두 상수 반복자이므로(실제로 동일한 타입일 수 있음), 이러한 멤버 함수들이 반환하는 반복자를 통해 컨테이너 요소를 변경하는 것은 불가능합니다.

libc++ 백포트는 cend() 를 C++98 모드로 지원합니다.

예제

#include <iostream>
#include <iterator>
#include <set>
#include <string>
int main()
{
    const std::multiset<std::string> words =
    {
        "some", "not", "sorted", "words",
        "will", "come", "out", "sorted",
    };
    for (auto it = words.begin(); it != words.end(); )
    {
        auto count = words.count(*it);
        std::cout << *it << ":\t" << count << '\n';
        std::advance(it, count); // all count elements have equivalent keys
    }
}

출력:

come:	1
not:	1
out:	1
some:	1
sorted:	2
will:	1
words:	1

참고 항목

시작 부분에 대한 반복자를 반환함
(public member function)
(C++11) (C++14)
컨테이너나 배열의 끝 부분에 대한 반복자를 반환함
(function template)