首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::pointer_traits::pointer_to

Defined in header <memory>

?

?

static pointer pointer_to( element_type& r );

(1)

(since C++11) (member of pointer_traits<Ptr> specialization)

static pointer pointer_to( element_type& r );

(2)

(since C++11) (member of pointer_traits<T*> specialization)

为其参数构造可取消引用的指针或类似指针的对象%28“花式指针”%29。

1%29这个函数的版本在非专门化。std::pointer_traits模板只需调用Ptr::pointer_to(r),如果PTR不提供静态成员函数pointer_to,此函数的实例化是编译时错误。

2%29该函数在专门化中的版本std::pointer_traits对于指针类型,返回std::addressof(r)

参数

r

-

reference to an object of type element_type&, except if element_type is void, in which case the type of r is unspecified

返回值

指向r,类型指针的[医]性状<>:指针。

例外

1%29未指定的%28通常与Ptr::pointer_to%29

2%29

noexcept规格:

noexcept

注记

Boost库版本函数的返回pointer(std::addressof(r))如果PTR::指针[医]不存在。

另见

addressof (C++11)

obtains actual address of an object, even if the & operator is overloaded (function template)

address (deprecated in C++17)

obtains the address of an object, even if operator& is overloaded (public member function of std::allocator)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com