【问题标题】:A query regarding allocator rebind关于分配器重新绑定的查询
【发布时间】:2018-05-10 02:54:43
【问题描述】:

C++ concepts: Allocator

希望了解以下内容:

A::template rebind::other (optional1)

注意:1 rebind 只是可选的(由std::allocator_traits 提供) 如果此分配器是SomeAllocator<T, Args> 形式的模板, 其中Args 是零个或多个附加模板参数。

为什么rebind 在上述情况下是可选的?

【问题讨论】:

标签: c++ c++11 allocator


【解决方案1】:

标准库总是通过std::allocator_traits 模板访问分配器。此模板提供rebind 的默认定义,如果它符合Alloc<U, Args> 的形式

rebind_alloc<T> Alloc::rebind<T>::other 如果存在,否则Alloc<T, Args> 如果这个AllocAlloc<U, Args> - cppreference.com : std::allocator_traits

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-14
    • 2016-05-09
    • 1970-01-01
    • 2021-01-24
    • 2012-07-17
    • 1970-01-01
    • 2016-03-16
    相关资源
    最近更新 更多