microsoft / cppwinrt

C++/WinRT
MIT License
1.64k stars 238 forks source link

as function missing inside implementation type #1288

Closed JaiganeshKumaran closed 1 year ago

JaiganeshKumaran commented 1 year ago

Version

No response

Summary

The implementation type doesn't have the as function, requiring you to use try_as (no exception) or QueryInterface instead. Please provide an as function for consistency.

Reproducible example

struct MainWindow : Microsoft::UI::Xaml::WindowT<MainWindow>
{
    MainWindow()
    {
        as<IWindowNative>(); //Error.
        try_as<IWindowNative>(); // Works.
    }
};

Expected behavior

No response

Actual behavior

No response

Additional comments

No response

JaiganeshKumaran commented 1 year ago

@kennykerr

kennykerr commented 1 year ago

Same as https://github.com/microsoft/cppwinrt/issues/1289 - this is probably a much smaller change, so I don't have any objections if you wish to contribute but there doesn't appear to be a lot of benefit and try_as is more efficient.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days.