다음을 통해 공유


pointer_traits 구조체

포인터 형식Ptr의 할당자를 설명하기 위해 형식 allocator_traits 개체에 필요한 정보를 제공합니다.

구문

template <class Ptr>
    struct pointer_traits;

설명

Ptr은 Ty * 형식의 원시 포인터 또는 다음 속성을 포함하는 클래스일 수 있습니다.

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
};

멤버

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입니다.

구조체

이름 설명
rebind 기본 포인터 형식을 지정된 형식으로 변환하려고 시도합니다.

메서드

이름 설명
pointer_to 클래스 Ptr의 개체에 대한 임의 참조를 변환합니다.

pointer_to

해당 함수가 있는 경우 Ptr::pointer_to(obj)를 반환하는 정적 메서드입니다. 그렇지 않으면 클래스 Ptr의 개체에 대한 임의 참조를 변환할 수 없습니다. Ptr이 원시 포인터이면 이 메서드는 addressof(obj)를 반환합니다.

static pointer pointer_to(element_type& obj);