Godot-proposals: Implement std::initializer_list<T> assignment for Vector<T>

Created on 13 Aug 2020  路  4Comments  路  Source: godotengine/godot-proposals

Describe the project you are working on:
The engine itself.

Describe the problem or limitation you are having in your project:
Not being able to do

Vector<String> _colors =  {...};

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Implement std::initializer_list for Vector<T> (and possibly other container types).

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
https://en.cppreference.com/w/cpp/utility/initializer_list

If this enhancement will not be used often, can it be worked around with a few lines of script?:
Multiple calls of insert, or append - append_all only works for other types of Godot containers.
None of these work outside a function.
One could use std::vector or other containers but these are not trivially convertible to Godot containers.

Is there a reason why this should be core and not an add-on in the asset library?:
This is literally a proposal for modifying core collection types.

core

Most helpful comment

I thought it would be worth to link this comment: https://github.com/godotengine/godot/issues/9694#issuecomment-485043847.

All 4 comments

Too modern ;p

I thought it would be worth to link this comment: https://github.com/godotengine/godot/issues/9694#issuecomment-485043847.

It's not like the engine doesn't make use of modern C++17 guarantees but the code base could use some modernisation.

@Vivraan Yeah, I think doing things this way, where you explicitly submit that a particular modernization feature should be added, and under what conditions it can/should be used, is a good way to go about it in the Godot project.

Was this page helpful?
0 / 5 - 0 ratings