Last active
August 8, 2024 14:32
-
-
Save kennykerr/2a5dd202274f49031adbd50e02d8b4d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace winrt; | |
using namespace Windows::Foundation; | |
struct Base: implements<Base, composable, IStringable> | |
{ | |
static IInspectable CreateInstance(IInspectable const& base, IInspectable& inner) | |
{ | |
return impl::composable_factory<Base>::CreateInstance<IInspectable>(base, inner); | |
} | |
hstring ToString() | |
{ | |
return L"base"; | |
} | |
}; | |
struct Derived : implements<Derived, composable, composing, IClosable> | |
{ | |
Derived() | |
{ | |
Base::CreateInstance(*this, m_inner); | |
} | |
void Close() {} | |
}; | |
int main() | |
{ | |
IInspectable derived = make<Derived>(); | |
derived.as<IClosable>().Close(); // outer query | |
derived.as<IStringable>().ToString(); // inner query | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment