Feel like I'm missing something painfully glaring, but I copied the code right off the book.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
#include <vector>
using std::cin;
using std::cout; using std::endl;
using std::vector;
int main()
{
vector<int> v{1,2,3,4,5,6,7,8,9};
for (auto &i : v)
i *= i;
for (auto i : v)
cout << i << " ";
cout << endl;
}
1 2
//Error appears right after v.
vector<int> v{1,2,3,4,5,6,7,8,9};
Thanks for the advice. The problem is with the compiler. Updating VS to include additional C++11 features (one of which is List Initialization) didn't seem to work for me.
There are other compiler alternatives but I guess this isn't a big deal right now. Just throwing this out there in case someone else is in the same wondering position as I am.
Initializer lists was added in 11.0 nov'12. Even the update page explicitly mentions this feature. I changed my project's Platform Toolset to the nov'12 update (following the instructions on the download page), but still doesn't seem to work.
Then again I'm still a scrub on all of this, so I'm not sure what other options are there to enable. Yeah Disch noticed that from the Apache list.
Code::blocks works though. I suppose GCC and Clang are the better compilers? (Pardon me if that isn't their right terminology)
Initializer lists were included in the Nov 12 CTP, however the library code wasn't modified to use them. I don't expect the std library will be until it's added as a non-preview type of feature.