pointer_traits 结构

提供由模板选件类必需 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。

JJ190031.collapse_all(zh-cn,VS.110).gifTypedef

名称

说明

typedef T2 difference_type

该类型 T2Ptr::difference_type,如果该类型存在,否则 ptrdiff_t。如果 Ptr 是为基元的指针,该类型是 ptrdiff_t

typedef T1 element_type

该类型 T1Ptr::element_type,如果该类型存在,否则 Ty。如果 Ptr 是为基元的指针,该类型是 Ty

typedef Ptr pointer

类型为 Ptr

JJ190031.collapse_all(zh-cn,VS.110).gif结构

名称

说明

pointer_traits::rebind

尝试将基础指针类型转换为指定的类型。

JJ190031.collapse_all(zh-cn,VS.110).gif方法

名称

说明

pointer_traits::pointer_to 方法

转换任意对选件类 Ptr对象。

要求

标头: <memory>

命名空间: std

请参见

参考

<memory>

allocator_traits 类