Skip to content
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

Make varray() variadic #84581

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Nov 7, 2023

Allows to make an array of any size and is probably faster thanks to loop assign instead of appending.

@KoBeWi KoBeWi added this to the 4.x milestone Nov 7, 2023
@KoBeWi KoBeWi requested a review from a team as a code owner November 7, 2023 14:36
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

I'd suggest rebasing as this is a bit old.

@akien-mga akien-mga modified the milestones: 4.x, 4.3 Apr 26, 2024
@KoBeWi KoBeWi force-pushed the varray(1,2,3,4,5,6,7,8,9,100); branch from 6f6677d to f647888 Compare April 26, 2024 12:33
@akien-mga akien-mga changed the title Make varray() variadic Make varray() variadic Apr 26, 2024
@akien-mga akien-mga merged commit 53ef784 into godotengine:master Apr 26, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@KoBeWi KoBeWi deleted the varray(1,2,3,4,5,6,7,8,9,100); branch April 26, 2024 13:27
@timothyqiu
Copy link
Member

timothyqiu commented Apr 27, 2024

Looks similar to this since we have initializer list support in Vector:

#define varray(...) Vector<Variant>({ __VA_ARGS__ })

Update: It compiles and seems to run normally. But compilation fails when I try to use a more simple version Vector<Variant>{ __VA_ARGS__ }. Probably caused by other macro expansions.

@KoBeWi
Copy link
Member Author

KoBeWi commented Apr 27, 2024

Note that would cause

Vector<Variant> v1;
Vector<Variant> v2 = varray(v1);

v2 to be copy of v1 instead of a containing array. I had this problem with #89782

@timothyqiu
Copy link
Member

Tested locally and it did not happen. It should not happen either. Constructors with an initializer list argument are preferred over regular ones (the copy constructor in this case).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants