I came across a source file here (in C). It uses a reasonable-but-strange style to initialize an array. I gave it a try in a shorter C++ program (please notice the "old way" in the code's comment):
arr.cc
#include <iostream>
using namespace std;
int main() {
long arr[] = { [0] = 100, [1] = 101 }; // old way: long arr[] = { 100, 101 };
cout << arr[0] << " " << arr[1] << endl;
}
The code is compiled like this:
g++-6 -std=c++14 arr.cc -o arr
When run, the output is this:
100 101
It passed with -std=c++14
? But I can't find it in a C++ reference website, like cppreference.com. Does it conform to the standard? If so, since which version?