# Brace initializers

**URL:** <https://forums.unrealengine.com/t/brace-initializers/329814>\
**Category:** Feedback & Requests\
**Tags:** container, unreal-engine, FeatureRequest, CPP, question\
**Created:** [August 25, 2015, 3:06am UTC](https://forums.unrealengine.com/t/brace-initializers/329814 "2015-08-25T03:06:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_3ea1abbe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_3ea1abbe](https://forums.unrealengine.com/u/anonymous_user_3ea1abbe)\
**Post date:** [August 25, 2015, 3:06am UTC](https://forums.unrealengine.com/t/brace-initializers/329814/1 "2015-08-25T03:06:06Z")

</div>

Is there somewhere a forum for feature requests akin to the debug forum?

I’d be convenient if the UE4 supplied containers supported [initializer lists](http://en.cppreference.com/w/cpp/language/list_initialization). In the same way one can initailize an std::vector (or for that mater any other std:: container, such as an unordered\_map) as:

```
  std::vector<int> myints = {1, 2, 3};

```

It would be nice to initialize a TArray as:

```
  TArray<int> myints = {1, 2, 3};

```

However, it doesn’t support this. Among other things, that tends to drag what should ideally be const data to be non-const as the first apparent alternative is a series of .Add()s into the container. Also, much of the API accepts such containers, and it’s a lot nicer to supply an inline { } list than go through the gyrations of manual construction. It makes for less code.

---

<div class="post-metadata">

**Author:** ![twiddle](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@twiddle](https://forums.unrealengine.com/u/twiddle)\
**Post date:** [August 25, 2015, 3:54am UTC](https://forums.unrealengine.com/t/brace-initializers/329814/2 "2015-08-25T03:54:16Z")

</div>

The only reason I could see that this might not be supported is the fact initializer lists are from C++11 and there may be issues with some of the compilers UE supports, not having full '11 support yet (MSVC definitely has some issues with C++14 from what I’ve seen, wouldn’t surprise me that they don’t fully do everything from '11 yet either).  
That aside though, this would be pretty handy.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_3ea1abbe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_3ea1abbe](https://forums.unrealengine.com/u/anonymous_user_3ea1abbe)\
**Post date:** [August 25, 2015, 1:41pm UTC](https://forums.unrealengine.com/t/brace-initializers/329814/3 "2015-08-25T13:41:25Z")

</div>

Good point Twiddle, it is new with C++11, so they might have to wait for some older compilers to age off into obsolescence. I think newer MSVC’s support it (probably \>= 2013), but VS2012 still had some major holes in their C++11 support, so it might not, and there are still folks using that version.

I have noticed UE4 uses some c++11 features in the code base, like the override keyword, so they’re at least not avoiding 11 entirely.

I might take a crack at adding this on my local source base, just to TArrays, to see how that goes.

(aside: I fixed my second example above which was meant to say TArray rather than std::vector)
