winrt::box_value function template (C++/WinRT)

Note

You can box not only scalar values, but also most kinds of arrays (with the exception of arrays of enumerations) by using the winrt::box_value function.

A function template that wraps (or boxes) a scalar or array value inside a reference class object so that it can be passed to a function that expects IInspectable. An overload of the function also exists for winrt::hstring. For more details, and code examples, see Boxing and unboxing values to IInspectable with C++/WinRT.

Syntax

winrt::Windows::Foundation::IInspectable box_value(winrt::hstring const& value);

template <typename T, typename = std::enable_if_t<!std::is_convertible_v<T, winrt::hstring>>>
winrt::Windows::Foundation::IInspectable box_value(T const& value);

Template parameters

typename T A scalar or array type.

Parameters

value A scalar or array value to box.

Return value

A reference class object containing the boxed value.

Requirements

Minimum supported SDK: Windows SDK version 10.0.17134.0 (Windows 10, version 1803)

Namespace: winrt

Header: %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt\Windows.Foundation.h

See also