最終更新日時(UTC):
が更新

履歴 編集

function
<set>

std::set::get_allocator

allocator_type get_allocator() const;          // C++03
allocator_type get_allocator() const noexcept; // C++11

概要

このコンテナで使用されているアロケータオブジェクトを取得する。

戻り値

このコンテナで使用されているアロケータオブジェクト

例外

投げない

計算量

定数時間

#include <iostream>
#include <set>

int main()
{
  std::set<int> c;
  int* p;

  p = c.get_allocator().allocate(2);

  p[0] = 42;
  p[1] = 43;

  std::cout << p[0] << " " << p[1] << std::endl;

  c.get_allocator().deallocate(p, 2);
}

出力

42 43

バージョン

言語

  • C++03
  • C++11

処理系

  • Clang: ?
  • GCC: ?
  • ICC: ?
  • Visual C++: 2002, 2003, 2005, 2008, 2010, 2012, 2013, 2015, 2017
    • 2012, 2013は、noexceptが実装されていないため、throw()が修飾されている。
    • 2015からは、noexceptが修飾されている。