名稱空間
變體
操作

std::allocator<T>::address

來自 cppreference.com
< cpp‎ | memory‎ | allocator
 
 
記憶體管理庫
(僅作說明*)
未初始化記憶體演算法
(C++17)
(C++17)
(C++17)
受約束的未初始化
記憶體演算法
C 庫

分配器
記憶體資源
垃圾回收支援
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
未初始化儲存
(直到 C++20*)
(直到 C++20*)
顯式生命週期管理
 
 
(1)
pointer address( reference x ) const;
(C++11 前)
pointer address( reference x ) const noexcept;
(C++11 起)
(C++17 中已棄用)
(C++20 中移除)
(2)
const_pointer address( const_reference x ) const;
(C++11 前)
const_pointer address( const_reference x ) const noexcept;
(C++11 起)
(C++17 中已棄用)
(C++20 中移除)

返回 x 的實際地址,即使存在過載的 operator&

[編輯] 引數

x - 要獲取地址的物件

[編輯] 返回值

x 的實際地址。

[編輯] 缺陷報告

下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。

缺陷報告 應用於 釋出時的行為 正確的行為
LWG 634
(N2436)
C++98 返回值為 &x
(受過載 operator& 的影響)
返回 x 的實際地址