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
概要
このコンテナで使用されているアロケータオブジェクトを取得する。
戻り値
このコンテナで使用されているアロケータオブジェクト
例外
投げない
例
#include <cassert>
#include <vector>
int main()
{
std::allocator<int> alloc;
std::vector<int> v(alloc);
std::allocator<int> result = v.get_allocator();
assert(result == alloc);
}
出力
バージョン
言語
- C++11
処理系
- Clang: ??
- GCC: 4.7.0 ✅
- ICC: ??
- Visual C++: 2002 ✅, 2003 ✅, 2005 ✅, 2008 ✅, 2010 ✅, 2012 ✅, 2013 ✅, 2015 ✅, 2017 ✅
- 2012, 2013は、
noexcept
が実装されていないため、throw()
が修飾されている。 - 2015からは、
noexcept
が修飾されている。
- 2012, 2013は、