std::pointer_traits<Ptr>::pointer_to
From cppreference.com
< cpp | memory | pointer traits
| ヘッダ <memory> で定義 |
||
| static pointer pointer_to( element_type& r ); |
(1) | (C++11以降) (member of pointer_traits<Ptr> specialization) |
| (2) | ||
static pointer pointer_to( element_type& r ) noexcept; |
(C++11以降) (C++20まで) (member of pointer_traits<T*> specialization) |
|
| static constexpr pointer pointer_to( element_type& r ) noexcept; |
(C++20以降) (member of pointer_traits<T*> specialization) |
|
引数への参照可能なポインタまたはポインタのようなオブジェクト(「ファンシーポインタ」)を構築します。
1) 非特殊化された std::pointer_traits テンプレートのこの関数のバージョンは、単に Ptr::pointer_to(r) を呼び出します。Ptr が静的メンバ関数
pointer_to を提供しない場合、この関数のインスタンス化はコンパイル時エラーになります。目次 |
[編集] パラメータ
| r | - | element_type 型のオブジェクトへの参照。ただし、element_type が void の場合は、r の型は未指定です。 |
[編集] 戻り値
r への参照可能なポインタ。型は pointer_traits<>::pointer です。
[編集] 例外
1) 未指定(通常は Ptr::pointer_to と同じ)。
[編集] 注釈
Boost.Intrusive ライブラリ版のこの関数は、Ptr::pointer_to が存在しない場合、pointer(std::addressof(r)) を返します。
[編集] 関連項目
| (C++11) |
& 演算子がオーバーロードされていても、オブジェクトの実際のアドレスを取得します(関数テンプレート) |
| (C++20まで) |
オブジェクトのアドレスを取得します。たとえ operator& がオーバーロードされていても。 (public member function of std::allocator<T>) |
| [static] (C++20)(optional) |
ファンシーポインターから生ポインターを取得する(pointer_to の逆)(public static member function) |
| (C++20) |
ポインタライクな型から生のポインタを取得します (関数テンプレート) |