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

A factory method that, when a C++/WinRT implementation type is provided as a type parameter, returns one of the following.

  • If you're authoring a component to be consumed from an app, then call make to return the default (projected) interface of the implementation type. In this case, your project doesn't contain a projected type.
  • If you're both implementing and consuming a runtime class within the same compilation unit—for example, authoring a type to be consumed from XAML UI—then call make to return an instance of the projected type.

For an explanation of the implementation type and projected type concepts, see Consume APIs with C++/WinRT and Author APIs with C++/WinRT. For more details, code, and a walkthrough of calling make in practice, see XAML; binding a control to C++/WinRT properties and collections. Also see make_self, which returns a com_ptr to an instance of the implementation type instead.

Also see Opt in to uniform construction, and direct implementation access.

Syntax

template <typename D, typename... Args>
auto make(Args&&... args);

Template parameters

typename D An implementation type.

Parameters

args Any constructor arguments for the constructor being invoked.

Return value

The default interface of the implementation type if no projected type exists, otherwise an instance of the projected type.

Requirements

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)

See also