- execution[meta header]
- cpo[meta id-type]
- std[meta namespace]
- cpp26[meta cpp]
namespace std {
struct get_allocator_t { unspecified };
constexpr get_allocator_t get_allocator{};
}
- unspecified[italic]
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>>);
}
- std::get_allocator[color ff0000]
- ex::prop[link execution/prop.md]
- C++26
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??