Add initializer_list to TPair and TMap request

There is initializer_list for TArray. It’s great. I can do next:

TArray<int32> = {1, 2, 3, 4, 5};

I think it would be nice works TMaps also:

TMap<int32, FName> map = { {1, "Hi!"}, {2, "Yo!"}, {3, "Lolz"} };

It possible if TPair will be extended with constructor with key and value, and TMap with initializer_list.

Thanks!

I’d love to see this too.

This would be very useful.

I would love this too

Would be a great addition. I hate having to do Map.Add for each element.

It is possible like this:

TMap<int32, float> map = { TPairInitializer<const int32&, const float&>(2, 5.f) };
1 Like