-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug:Compiling Error with C++20, inheriting of winrt::implements #1418
Comments
You can only have one instance of winrt::implements in a class hierarchy. In |
I tried this way, but it doesn't work. my code just works fine with C++17, but not work with C++20, I wonder know if c++/winrt is compatible with C++20; |
C++/WinRT is compatible with C++20, what you are seeing is that this code should've been rejected in C++17 mode but wasn't (and in fact Clang does reject it in C++17). This MSVC specific compiler bug was fixed with C++20, so the code is now properly rejected in C++20 mode.
Alternatively, you can have only the most derived classes make use of Another alternative is making use of WinRT composition with |
thank you for the reply @sylveon . the reason I want to use
with above code, there will be no lifetime issue of in my code, the Aclass is actually an abstract class, I wonder what's the right way to write an user-defined |
You can do the same with Also, if Aclass is strictly an interface, you can define it as such: MIDL_INTERFACE("SOME-GUID") IAclass : IUnknown
{
virtual void SayHello() = 0;
virtual std::string GetString() = 0; // no need to conform to COM interface restrictions
}; And then do like this class Bclass : public winrt::implements<Bclass, IAclass> |
Version
2.0.240405.15
Summary
Hello community,
in my WinUI3 project (C++/WinRT), in order to use
winrt::weak_ref<>
&get_weak()
for events. I defined a base class as below:class IDrawable: public winrt::implements<IDrawable, winrt::Windows::Foundation::IInspectable>
and a "derived" class as below:
class FlowLine : public winrt::implements<FlowLine,IDrawable,winrt::Windows::Foundation::IInspectable>
this pattern works fine for me with C++17 in Visual Studio Community 2022, however, when I try to change to C++20, the same code can not be compiled, and I got errors during compiling as below
'to_abi': no matching overloaded function found
any thoughts?
Reproducible example
Expected behavior
these code has been compiled sucessfully with Visual Studio Community 2022 with C++17, and the app works as expected for me.
however, the same code can not be compiled with C++20, I expected to compile these code sucessfully with C++20 as I dont change even one character.
Actual behavior
Error during Compiling:
C2672 'to_abi': no matching overloaded function found
Additional comments
No response
The text was updated successfully, but these errors were encountered: