winrt::handle_type 結構範本 (C++/WinRT)

winrt::handlewinrt::file_handle結構等的範本。

注意

您可以在) 中 \cppwinrt\winrt\base.h 定義自己的控制碼特性 (,例如,handle_traitsfile_handle_traits,並將其與winrt::handle_type搭配 typename T 使用。 將其中一個範例複製到 base.h 您自己的原始程式碼檔案,並提供您自己的控制碼類型和實作。 使用C++ Windows MSDN Magazine 文章中有更多詳細資料。

語法

template <typename T>
struct handle_type

範本參數

typename T 特性類型,指定 (控制碼、檔案控制碼或其他類型) 表示的控制碼類型。

規格需求

最低支援的 SDK:Windows SDK 10.0.17134.0 版 (Windows 10版本 1803)

命名空間: winrt

標頭: %WindowsSdkDir%IncludeWindowsTargetPlatformVersion <> \cppwinrt\winrt\base. (h 預設包含)

成員類型別名

別名名稱 類型
handle_type::type typename T::type的同義字,其中Ttypename T 樣板參數。

建構函式

建構函式 描述
handle_type::handle_type建構函式 使用輸入資料的複本或移動,初始化 handle_type 結構的新實例。

成員函數

函式 描述
handle_type::attach 函式 附加至控制碼值,並取得其擁有權。
handle_type::close 函式 關閉基礎控制碼。
handle_type::d etach 函式 從基礎控制碼中斷連結。
handle_type::get 函式 傳回基礎控制碼,您應該必須將它傳遞至函式。
handle_type::p ut 函式 傳回基礎控制碼的位址;此函式可協助您呼叫方法,透過控制碼的指標傳回參考做為 out 參數。

成員運算子

運算子 描述
handle_type::operator bool 檢查 handle_type 物件目前是否代表有效的控制碼。
handle_type::operator= (指派運算子) 將值指派給 handle_type 物件。

免費函式

函式 描述
swap 函式 交換兩 個handle_type 參數的內容,使其包含彼此的控制碼。

handle_type::handle_type建構函式

使用輸入資料的複本或移動,初始化 handle_type 結構的新實例。

語法

handle_type() noexcept;
explicit handle_type(handle_type::type value) noexcept;
handle_type(handle_type&& other) noexcept;

參數

value 初始化 handle_type 物件的 值。

other 另一個 初始化handle_type 物件的handle_type

handle_type::attach 函式

附加至控制碼值,並取得其擁有權。

語法

void attach(handle_type::type value) noexcept;

參數

value 要附加的控制碼值。

handle_type::close 函式

關閉基礎控制碼。

語法

void close() noexcept;

handle_type::d etach 函式

從基礎控制碼中斷連結。

語法

handle_type::type detach() noexcept;

傳回值

先前由 handle_type 物件表示的基礎控制碼。

handle_type::get 函式

傳回基礎控制碼,您應該必須將它傳遞至函式。

語法

handle_type::type get() const noexcept;

傳回值

handle_type 物件表示的基礎控制碼。

handle_type::p ut 函式

傳回基礎控制碼的位址;此函式可協助您呼叫方法,透過控制碼的指標傳回參考做為 out 參數。

語法

handle_type::type* put() noexcept;

傳回值

由 handle_type物件表示的基礎控制碼位址。

handle_type::operator bool

檢查 handle_type 物件目前是否代表有效的控制碼。

語法

explicit operator bool() const noexcept;

傳回值

true 如果 handle_type 物件目前代表有效的控制碼,則為 ,否則 false 為 。

handle_type::operator= (指派運算子)

將值指派給 handle_type 物件。

語法

winrt::handle_type& operator=(winrt::handle_type&& other) noexcept;

參數

other要指派給handle_type物件的handle_type值。

傳回值

handle_type物件的參考。

swap 函式

交換兩 個handle_type 參數的內容,使其包含彼此的控制碼。

語法

void swap(winrt::handle_type& left, winrt::handle_type& right) noexcept;

參數

leftrighthandle_type值,其控制碼與另一個參數的控制碼相互交換。

另請參閱