I have been working with some C error codes that are organized in an enum. I noticed that if I tried to write a function that processes these error codes within a struct, then I could not use a UFCS-style call.

For instance, in the code below, I could use Baz but not Caz. It seems to work when I use the alternate version of Caz calling a non-member function.

Bug?


enum X
{
        A = 1,
}

struct Foo
{
        X Bar(X x)
        {
                return x;
        }
        
        X Baz()
        {
                auto result = X.A;
                return Bar(result);
        }
        
        /*
        X Caz()
        {
                auto result = X.A;
                return result.Bar();
        }
        */
        
        X Caz_alt()
        {
                auto result = X.A;
                return result.Bar_alt();
        }
}

X Bar_alt(X x)
{
        return x;
}

void main()
{
        auto foo = Foo();
        auto result = foo.Baz();
        //auto result2 = foo.Caz();
        auto result3 = foo.Caz_alt();
}

Reply via email to