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

履歴 編集

function
<string>

std::basic_string::get_allocator

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

概要

basic_stringが内包しているアロケータを取得する。

戻り値

basic_stringが内包しているアロケータ

例外

投げない

備考

noexcept修飾はC++11で追加された。

#include <cassert>
#include <string>

int main()
{
  std::allocator<char> alloc;
  std::string s(alloc);

  std::allocator<char> result = s.get_allocator();

  assert(result == alloc);
}

出力

バージョン

言語

  • C++03
  • C++11

処理系

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

参照