std::pointer_traits::pointer_to

定义于头文件 <memory>
static pointer pointer_to( element_type& r );
(1) (C++11 起)
(pointer_traits<Ptr> 特化的成员)
static pointer pointer_to( element_type& r ) noexcept;
(2) (C++11 起)
(pointer_traits<T*> 特化的成员)

构造一个指向其参数的可解引用指针或类指针对象(“缀饰指针”)。

1) 此函数于非特化 std::pointer_traits 模板的版本简单地调用 Ptr::pointer_to(r) ,且若 Ptr 不提供静态成员函数 pointer_to ,则此函数的实例化为编译时错误。
2) 此函数于 std::pointer_traits 为指针类型特化的版本返回 std::addressof(r)

目录

参数

r - element_type& 类型的到对象引用,除非 element_type 为 void ,此情况下 r 的类型未指定

返回值

指向 r 的可解引用指针,拥有 pointer_traits<>::pointer 类型。

异常

1) 未指定(通常同 Ptr::pointer_to

注意

若 Ptr::pointer_to 不存在,则此函数的 Boost.Intrusive 库版本 返回 pointer(std::addressof(r))

参阅

(C++11)
获得对象的实际地址,即使重载了 & 运算符
(函数模板)
(C++17 中弃用)
获得对象的地址,即使重载了 operator&
(std::allocator 的公开成员函数)
[静态] (C++20)
从缀饰指针获得裸指针( pointer_to 的反函数)
(公开静态成员函数)
(C++20)
从仿指针类型获得裸指针
(函数模板)

版本历史

  • (当前 | 先前 2017年11月14日 (二) 08:28Fruderica讨论 | 贡献 . . (1,661字节) (+88). . (+) (撤销)
  • 当前 | 先前 2017年9月13日 (三) 04:22Fruderica讨论 | 贡献 . . (1,573字节) (-9). . (撤销)
  • 当前 | 先前 2017年5月9日 (二) 09:43Fruderica讨论 | 贡献. . (1,582字节) (-1,138). . (撤销)
  • 当前 | 先前 2013年7月2日 (二) 09:05P12bot讨论 | 贡献 . . (2,720字节) (-62). . (Use {{lc}}. Update links. Various fixes.) (撤销)
  • 当前 | 先前 2012年11月2日 (五) 15:44P12bot讨论 | 贡献 . . (2,782字节) (+353). . (r2.7.3) (机器人添加:de, en, es, fr, it, ja, pt, ru) (撤销)
  • 当前 | 先前 2012年10月27日 (六) 03:39P12讨论 | 贡献 . . (2,429字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前 2012年10月26日 (五) 06:00TranslationBot讨论 | 贡献. . (2,429字节) (-61). . (Translated from the English version using Google Translate) (撤销)
  • 当前 | 先前 2012年10月25日 (四) 14:10P12讨论 | 贡献 . . (2,490字节) (0). . (1个修订: Translate from the English version) (撤销)
  • 当前 | 先前) 2012年10月25日 (四) 12:00TranslationBot讨论 | 贡献. . (2,490字节) (+2,490). . (Translated from the English version using Google Translate)