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++: ??