Skip to content

Conversation

@reflectronic
Copy link
Contributor

Move constructors need the same special handling as copy constructors do.

One scenario that this fixes is functions which return structs. Previously, for C++ code like this:

struct MyStruct
{
    double r;
    double g;
    double b;
};

MyStruct MyFunction()
{
    MyStruct myStruct;
    return myStruct;
}

the MyFunction function would be translated as such:

public static MyStruct MyFunction()
{
    MyStruct myStruct = new MyStruct();
    return new MyStruct(myStruct);
}

This patch removes the explicit constructor invocation.

@tannergooding
Copy link
Member

Talked with @reflectronic offline and while ideally this would check if the constructors are implicit, they can't due to lack of expose surface area today.
I'll log an issue to get that exposed and to update this logic.

@tannergooding tannergooding merged commit 280d879 into dotnet:master Jan 8, 2021
@reflectronic reflectronic deleted the fix-move-constructor branch January 8, 2021 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants