description | title | dev_langs | ms.date | ms.topic | keywords | ms.workload | ||
---|---|---|---|---|---|---|---|---|
The template for the winrt::handle and winrt::file_handle structs. |
winrt::handle_type struct template (C++/WinRT) |
|
05/14/2018 |
language-reference |
windows 10, uwp, standard, c++, cpp, winrt, projection, api, reference |
|
The template for the winrt::handle and winrt::file_handle structs, among others.
Note
You can define your own handle traits (see, for example, handle_traits or file_handle_traits in \cppwinrt\winrt\base.h
), and use them with winrt::handle_type as typename T
. Copy one of those examples from base.h
into your own source code file, and provide your own handle type and implementation. There are more details in the MSDN Magazine article Windows with C++.
template <typename T>
struct handle_type
typename T
A traits type that specifies the kind of handle being represented (a handle, a file handle, or some other type).
Minimum supported SDK: Windows SDK version 10.0.17134.0 (Windows 10, version 1803)
Namespace: winrt
Header: %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt\base.h (included by default)
Alias name | Type |
---|---|
handle_type::type | A synonym for typename T::type, where T is the typename T template parameter. |
Constructor | Description |
---|---|
handle_type::handle_type constructor | Initializes a new instance of the handle_type struct, optionally with a copy or move of the input data. |
Function | Description |
---|---|
handle_type::attach function | Attaches to a handle value, and takes ownership of it. |
handle_type::close function | Closes the underlying handle. |
handle_type::detach function | Detaches from the underlying handle. |
handle_type::get function | Returns the underlying handle should you need to pass it to a function. |
handle_type::put function | Returns the address of the underlying handle; this function helps you call methods that return references as out parameters via a pointer to a handle. |
Operator | Description |
---|---|
handle_type::operator bool | Checks whether or not the handle_type object currently represents a valid handle. |
handle_type::operator= (assignment operator) | Assigns a value to the handle_type object. |
Function | Description |
---|---|
swap function | Swaps the contents of the two handle_type parameters so that they contain one another's handle. |
Initializes a new instance of the handle_type struct, optionally with a copy or move of the input data.
handle_type() noexcept;
explicit handle_type(handle_type::type value) noexcept;
handle_type(handle_type&& other) noexcept;
value
A value that initializes the handle_type object.
other
Another handle_type that initializes the handle_type object.
Attaches to a handle value, and takes ownership of it.
void attach(handle_type::type value) noexcept;
value
A handle value to attach to.
Closes the underlying handle.
void close() noexcept;
Detaches from the underlying handle.
handle_type::type detach() noexcept;
The underlying handle formerly represented by the handle_type object.
Returns the underlying handle, should you need to pass it to a function.
handle_type::type get() const noexcept;
The underlying handle represented by the handle_type object.
Returns the address of the underlying handle; this function helps you call methods that return references as out parameters via a pointer to a handle.
handle_type::type* put() noexcept;
The address of the underlying handle represented by the handle_type object.
Checks whether or not the handle_type object currently represents a valid handle.
explicit operator bool() const noexcept;
true
if the handle_type object currently represents a valid handle, otherwise false
.
Assigns a value to the handle_type object.
winrt::handle_type& operator=(winrt::handle_type&& other) noexcept;
other
A handle_type value to assign to the handle_type object.
A reference to the handle_type object.
Swaps the contents of the two handle_type parameters so that they contain one another's handle.
void swap(winrt::handle_type& left, winrt::handle_type& right) noexcept;
left
right
A handle_type value whose handle to mutually swap with that of the other parameter.