Is there already a way where I can initialize an array directly in a struct? Like this:
struct S { int arr[50] = {5}; } I know this only initializes the first element of the array, but is there any way to write something similar with g++ but that can initialize all elements of the array with 5?
I've read that with gcc we can use designated intializers int arr[50] = {[0 ... 49] = 5}; but this won't be possible in C++.
struct S { std::array<int, 50> arr = []{ decltype(arr) rv; rv.fill(5); return rv; }(); };