关于分配器重新绑定的查询
A query regarding allocator rebind
之下
想澄清以下内容:
A::template rebind::other (optional1)
Notes: 1 rebind is only optional (provided by std::allocator_traits
)
if this allocator is a template of the form SomeAllocator<T, Args>
,
where Args
is zero or more additional template parameters.
为什么在上述情况下 rebind
是可选的?
标准库总是通过 std::allocator_traits
模板访问分配器。如果此模板符合 Alloc<U, Args>
形式,则它会提供 rebind
的默认定义
rebind_alloc<T>
Alloc::rebind<T>::other
if present, otherwise Alloc<T, Args>
if this Alloc
is Alloc<U, Args>
- cppreference.com : std::allocator_traits
想澄清以下内容:
A::template rebind::other (optional1)
Notes: 1 rebind is only optional (provided by
std::allocator_traits
) if this allocator is a template of the formSomeAllocator<T, Args>
, whereArgs
is zero or more additional template parameters.
为什么在上述情况下 rebind
是可选的?
标准库总是通过 std::allocator_traits
模板访问分配器。如果此模板符合 Alloc<U, Args>
rebind
的默认定义
rebind_alloc<T>
Alloc::rebind<T>::other
if present, otherwiseAlloc<T, Args>
if thisAlloc
isAlloc<U, Args>
- cppreference.com : std::allocator_traits