Skip to content

Bug:Compiling Error with C++20, inheriting of winrt::implements #1418

@ifgotmoney

Description

@ifgotmoney

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

//using a winui3 desktop app template C++/WinRT, define two classes as below, both of them are not runtimeclass, just inheriting from winrt::implements<>, in order to use winrt::weak_ref<> template for these classes.

// class A
class Aclass : public winrt::implements<Aclass,winrt::Windows::Foundation::IInspectable>
{
public:
    Aclass();
    virtual void SayHello()=0;
}

//class B
class Bclass : public winrt::implements<Bclass,Aclass,winrt::Windows::Foundation::IIspectable>
{
public:
     Bclass();
     virtual void SayHello() override;
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions