1

This code does not compile on VS2010:

struct Point {
    float x;
    float y;
};

void do_something(Point p) {
    // something happens here
}

int main(int argc, char **argv) {
    do_something({10, 11});
}

Are there any versions of C++ where this is legal syntax?

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
peco
  • 1,411
  • 3
  • 17
  • 38

1 Answers1

4

This looks like aggregate initialization to me. It should work in VS2013.

EDIT: Confirmed, this should work on a c++11 compiler. Also, it isn't an array literal, it's aggregate initialization. You can find the rules on it here and here. You might be able to download a newer compiler and run it on the older IDE, but short of that I don't think VS2010 can run this.

Community
  • 1
  • 1
Weak to Enuma Elish
  • 4,622
  • 3
  • 24
  • 36
  • 2
    Nah, you're pretty much out of luck there, @peco. The quick answer is c++11 was the C++ standard approved in 2011, so the support in MSVC 2010 is doomed to be spotty. They did get shared and unique pointers in, so they were trying. Which is more than I can say for their support of C. – user4581301 Sep 14 '15 at 05:01