winrt:: make 函數範本(C++/WinRT)winrt::make function template (C++/WinRT)

Factory 方法,當提供 C++/WinRT實類型做為型別參數時,會傳回下列其中一項。A factory method that, when a C++/WinRT implementation type is provided as a type parameter, returns one of the following.

  • 如果您要撰寫要從應用程式取用的元件,請呼叫make來傳回實類型的預設(投射)介面。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.
  • 如果您同時在相同的編譯單位中執行和使用執行時間類別—例如,撰寫要從 XAML UI 取用的類型—然後呼叫make來傳回投影類型的實例。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.

如需實作為型別和預測型別概念的說明,請參閱使用api 搭配C++/WinRT和使用 C++/WinRT 撰寫 apiFor an explanation of the implementation type and projected type concepts, see Consume APIs with C++/WinRT and Author APIs with C++/WinRT. 更多詳細資料、程式碼,以及呼叫實務的逐步解說,請參閱XAML; 將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. 另請參閱make_selfAlso see make_self.

語法Syntax

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

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

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

範本參數Template parameters

typename D 的實作為型別。typename D An implementation type.

參數Parameters

args 所叫用之函式的任何函式引數。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

最低支援 SDK: Windows SDK 版本10.0.17134.0 (Windows 10,版本1803)Minimum supported SDK: Windows SDK version 10.0.17134.0 (Windows 10, version 1803)

命名空間: winrtNamespace: winrt

標頭% WindowsSdkDir% Include<WindowsTargetPlatformVersion > \cppwinrt\winrt\base.h (預設包含)Header %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt\base.h (included by default)

另請參閱See also