如何防止在C17分配器中再次将长尾词重新绑定?
- 内容介绍
- 文章标签
- 相关推荐
本文共计256个文字,预计阅读时间需要2分钟。
在C++17之前,如果你有一个分配器,例如`Allocator`,你可以使用`rebind`结构。但现在,在C++17中,重新绑定结构已被弃用。构建分配器的解决方案是使用`T, size_t`来自分配器`T2, size_t`。仅移除`st`。
在c 17之前,如果你有一个分配器,如Allocator< typename,size_t>你可以使用rebind结构.但现在,在C 17中,重新绑定结构已被弃用.
构建分配器的解决方案是什么< T,size_t>来自分配器< T2,size_t>? 仅弃用std :: allocator的重新绑定成员模板.如果您使用自己的类,仍然可以定义重新绑定.
通过std::allocator_traits执行,如:
using AllocatorForU = std::allocator_traits<AllocatorForT>::template rebind_alloc<U>;
AllocatorTemplate< T,OtherTypes ...>的rebind_alloc的默认值是AllocatorTemplate< U,OtherTypes ...>,适用于std :: allocator,这就是为什么不推荐使用std :: allocator< T> :: rebind的原因.您必须为您的类定义它,因为它具有非类型模板参数.
本文共计256个文字,预计阅读时间需要2分钟。
在C++17之前,如果你有一个分配器,例如`Allocator`,你可以使用`rebind`结构。但现在,在C++17中,重新绑定结构已被弃用。构建分配器的解决方案是使用`T, size_t`来自分配器`T2, size_t`。仅移除`st`。
在c 17之前,如果你有一个分配器,如Allocator< typename,size_t>你可以使用rebind结构.但现在,在C 17中,重新绑定结构已被弃用.
构建分配器的解决方案是什么< T,size_t>来自分配器< T2,size_t>? 仅弃用std :: allocator的重新绑定成员模板.如果您使用自己的类,仍然可以定义重新绑定.
通过std::allocator_traits执行,如:
using AllocatorForU = std::allocator_traits<AllocatorForT>::template rebind_alloc<U>;
AllocatorTemplate< T,OtherTypes ...>的rebind_alloc的默认值是AllocatorTemplate< U,OtherTypes ...>,适用于std :: allocator,这就是为什么不推荐使用std :: allocator< T> :: rebind的原因.您必须为您的类定义它,因为它具有非类型模板参数.

