namespace std {
struct get_allocator_t { unspecified };
inline constexpr get_allocator_t get_allocator{};
}
概要
get_allocator
は、クエリ可能オブジェクトからアロケータを取得するクエリオブジェクトである。
コア定数式forwarding_query(get_allocator)
はtrue
値を返す。
効果
呼び出し式get_allocator(env)
は下記と等価であり、適格であれば説明専用コンセプトsimple-allocator
を満たす型の値となる。
- 引数
env
がconst修飾されたcenv
を用いて、式cenv.query(get_allocator)
template<class Alloc>
concept simple-allocator =
requires(Alloc alloc, size_t n) {
{ *alloc.allocate(n) } -> same_as<typename Alloc::value_type&>;
{ alloc.deallocate(alloc.allocate(n), n) };
} &&
copy_constructible<Alloc> &&
equality_comparable<Alloc>;
例外
投げない
カスタマイゼーションポイント
const修飾クエリ可能オブジェクトcenv
に対して式cenv.query(get_allocator)
が呼び出される。
このとき、noexcept(cenv.query(get_allocator)) == true
であること。
例
#include <concepts>
#include <memory>
#include <execution>
namespace ex = std::execution;
int main()
{
auto env = ex::prop(std::get_allocator, std::allocator<int>{});
auto alloc = std::get_allocator(env);
static_assert(std::same_as<decltype(alloc), std::allocator<int>>);
}
出力
バージョン
言語
- C++26
処理系
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??