public member function
<set>

std::multiset::end

      iterator end();const_iterator end() const;
      iterator end() noexcept;const_iterator end() const noexcept;
返回指向末尾的迭代器
返回一個指向 multiset 容器中尾後元素的迭代器。

尾後元素是 multiset 容器中最後一個元素之後的理論上的元素。它不指向任何元素,因此不應被解引用。

由於標準庫函式使用的範圍不包括其結束迭代器指向的元素,因此此函式通常與 multiset::begin 結合使用,以指定包含容器中所有元素的範圍。

如果容器為空,則此函式返回的與 multiset::begin 相同。

引數



返回值

指向容器中“尾後”元素的迭代器。

如果 multiset 物件是 const 限定的,則函式返回一個const_iterator。否則,它返回一個iterator.

成員型別iteratorconst_iterator是指向元素的雙向迭代器型別。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// multiset::begin/end
#include <iostream>
#include <set>

int main ()
{
  int myints[] = {15,98,77,77,39};
  std::multiset<int> mymultiset (myints,myints+5);

  std::cout << "mymultiset contains:";
  for (std::multiset<int>::iterator it=mymultiset.begin(); it!=mymultiset.end(); ++it )
    std::cout << ' ' << *it;

  std::cout << '\n';

  return 0;
}

輸出
mymultiset contains: 15 39 77 77 98


複雜度

常量。

迭代器有效性

沒有變化。

資料競爭

訪問容器(const 和非 const 版本都不會修改容器)。
同時訪問 multiset 的元素是安全的。

異常安全

無異常保證:此成員函式從不丟擲異常。
還可以保證返回的迭代器的複製構造或賦值永遠不會引發異常。

另見