提供由模板选件类必需 allocator_traits 对象描述用于指针类型 Ptr的赋值程序的信息。
template<class Ptr>
struct pointer_traits;
备注
PTR可以是类型 Ty * 或具有下列特性的选件类为基元的指针。
template<class Ty, class... Rest>
struct Ptr
{ // describes a pointer type usable by allocators
typedef Ptr pointer;
typedef T1 element_type; // optional
typedef T2 difference_type; // optional
template<class Other>
using rebind = typename Ptr<Other, Rest...>; // optional
static pointer pointer_to(element_type& obj); // optional
};
![]() |
---|
在C++标准指定 rebind 成员用作别名模板时,Visual C++实现rebind作为 struct。 |
Typedef
名称 |
说明 |
---|---|
typedef T2 difference_type |
该类型 T2 是 Ptr::difference_type,如果该类型存在,否则 ptrdiff_t。如果 Ptr 是为基元的指针,该类型是 ptrdiff_t。 |
typedef T1 element_type |
该类型 T1 是 Ptr::element_type,如果该类型存在,否则 Ty。如果 Ptr 是为基元的指针,该类型是 Ty。 |
typedef Ptr pointer |
类型为 Ptr。 |
结构
名称 |
说明 |
---|---|
pointer_traits::rebind |
尝试将基础指针类型转换为指定的类型。 |
方法
名称 |
说明 |
---|---|
转换任意对选件类 Ptr对象。 |
要求
标头: <memory>
命名空间: std